Setting up config.php using local MS SQL Server connection

Setting up config.php using local MS SQL Server connection

datatables97datatables97 Posts: 5Questions: 2Answers: 0

I am having trouble setting up the demo examples connecting to a local SQL Server.

I have a connection string that works in some generic php code, but I cannot translate this into the config.php to make the exampoles work.

PDO string that works:
("sqlsrv:Server=PROGAMMER01-201\SQLEXPRESS2014;Database=3rdParty_DB;ConnectionPooling=0", "usrX","pw")

  1. What does the config.php look like using these parameters?

  2. I saw in the forums that you can add just a PDO string entry in the config,
    What would that look like using these parameters?
    "pdo" => "??"

Thanks...

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    edited March 2018
    <?php if (!defined('DATATABLES')) exit(); // Ensure being used in DataTables env.
     
    // Enable error reporting for debugging (remove for production)
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
      
      
    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     * Database user / pass
     */
    $sql_details = array(
        "type" => "Sqlserver",    // Database type: "Mysql", "Postgres", "Sqlserver", "Sqlite" or "Oracle"
        "user" => "usrX",    // User name
        "pass" => "pw",    // Password
        "host" => "PROGAMMER01-201\SQLEXPRESS2014",    // Database server
        "port" => "",    // Database port (can be left empty for default)
        "db"   => "3rdParty_DB",    // Database name
        "dsn"  => ""     // PHP DSN extra information. Set as `charset=utf8` if you are using MySQL
    );
    

    should do it.

    Allan

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    I missed part 2 - you can use:

    <?php if (!defined('DATATABLES')) exit(); // Ensure being used in DataTables env.
      
    // Enable error reporting for debugging (remove for production)
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
       
       
    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     * Database user / pass
     */
    $sql_details = array(
        "pdo" => "..."
    );
    

    Allan

  • datatables97datatables97 Posts: 5Questions: 2Answers: 0

    Allan,

    Thanks for part 1.. That’s pretty straight forward.. So I must be another issue... I will research more...

    Part 2, What u wrote was the format I read in the forums.. I just neeed help in converting the connection string provided in this example to that object.. The quotes in the string were messing me up.. I think.. or.. as I mentioned in part 1... I might have a different issue. If u could show me the correct value. Then at least I know that’s right..

    Thanks!!

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Answer ✓

    Sorry yes, that wasn't very clear from my post. Hopefully this helps:

    $pdo = new PDO( "sqlsrv:Server=...", $user, $pass );
    
    $sql_details = array(
        "pdo" => $pdo
    );
    

    Allan

  • datatables97datatables97 Posts: 5Questions: 2Answers: 0

    Cool thanks... Stil a novice with php object oriented stuff.. learned something new w your example..

    As a side note..

    I used your first example and everything started working.. So, I started to change up some parameters to see if were it broke. And once I broke it.. I couldn’t get it to work again... So I cleared my cache.. closed the browser and rebooted the PC.. Then after a bit.. it stated widking again..

    It’s working and I am leaving it alone!! Lol

    On to some real coding!!

    Thanks so much for the support! Very helpful!!

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Answer ✓

    Interesting. The Editor server-side components don't have their own configuration cache, so I'm not 100% sure what happened there. However, if its working now, on to bigger and better things... :).

    Allan

This discussion has been closed.