SQL to MYSQL OR how to create connection in PHP to connect to SQL server

sdlrs6

Well-known member
  • Feb 20, 2008
    30,449
    921
    113
    34
    In the Sky
    Machanla mata help ekak diyanko MSSQL database ekak MYSQL ekata attached karanna puluwan widiha hari

    PHP/JAVA wala SQL server connection eka hadaganan widihai


    Loku Udawwak machan:)
     
    Last edited:

    TNHM

    Well-known member
  • Jan 3, 2017
    5,328
    15,489
    113
    SQL is definition.
    MYSQL is an implementation of SQL

    So what did you meant by SQL ?
     

    K_ZONE

    Well-known member
  • May 28, 2009
    5,155
    4,056
    113
    invoke db "Injected Memory"
    පුලුවන් බං, SQL Syntax ටිකක් වෙනස්, ඒත් දෙකටම හරියන්න ලියන්න පුලුවන්,
    ගොඩක් CMS ඔය දෙකටම වෙනස්ක් නැතුව පාවිච්චි කරනවා, Open Source එකක් ඇරගත්තා නම් ප්‍රශන් ගොඩකට උත්තර ලැබෙයි,

    MY SQL වලට වඩා TSQL server එකට මම නම් පට්ට කැමතියි. Profile කරන්න Debug කරන්න Sql server එකේ පුරුදු උනාට පස්සෙ මයිසීකුවල් මොන හුයන්නක් ද කියලා හිතෙනවා :P log ෆයිල් බල බල, 3rd party tools දාගෙන, MS SQL වල නම ඔක්කොම එනවා, තව Redgate toolbelt වගේ එකක්දාගත්තම දවස් ගානක වැඩ ඉතුරු වෙනවා.
     
    • Like
    Reactions: sdlrs6

    sdlrs6

    Well-known member
  • Feb 20, 2008
    30,449
    921
    113
    34
    In the Sky
    පුලුවන් බං, SQL Syntax ටිකක් වෙනස්, ඒත් දෙකටම හරියන්න ලියන්න පුලුවන්,
    ගොඩක් CMS ඔය දෙකටම වෙනස්ක් නැතුව පාවිච්චි කරනවා, Open Source එකක් ඇරගත්තා නම් ප්‍රශන් ගොඩකට උත්තර ලැබෙයි,

    MY SQL වලට වඩා TSQL server එකට මම නම් පට්ට කැමතියි. Profile කරන්න Debug කරන්න Sql server එකේ පුරුදු උනාට පස්සෙ මයිසීකුවල් මොන හුයන්නක් ද කියලා හිතෙනවා :P log ෆයිල් බල බල, 3rd party tools දාගෙන, MS SQL වල නම ඔක්කොම එනවා, තව Redgate toolbelt වගේ එකක්දාගත්තම දවස් ගානක වැඩ ඉතුරු වෙනවා.
    Coding thiyenawanam ewapanko macho:D
    mata me report hadanan pulwuanda balanan ona MS SQL database eken ekai:cool:
     

    D-ICE

    Active member
  • Jul 16, 2008
    720
    233
    43
    මන් ගාව code එකක් තිබ්බ.ගෙදර ගියාම දාන්නම්..
     

    D-ICE

    Active member
  • Jul 16, 2008
    720
    233
    43
    <?php

    $serverName = "serverName"; //serverName\instanceName

    // Since UID and PWD are not specified in the $connectionInfo array,
    // The connection will be attempted using Windows Authentication.
    $connectionInfo = array('Database' => 'DB_NAME', "UID" => "DB_UserName", "PWD" => "DB_Password");
    $conn = sqlsrv_connect( $serverName, $connectionInfo);

    if( $conn ) {
    echo "Connection established.<br />";
    }else{
    echo "Connection could not be established.<br />";
    die( print_r( sqlsrv_errors(), true));
    }








    $sql = "SELECT * FROM Your_table_name WHERE EmployeeID='$empno' AND Date BETWEEN '$from' AND '$to' ";
    $stmt = sqlsrv_query($conn, $sql) or die(sqlsrv_error());
    if ($stmt === false) {
    die(print_r(sqlsrv_errors(), true));
    }

    try {
    while ($row = sqlsrv_fetch_array($stmt)) {


    }
    } catch (Exception $ex) {
    echo $ex->getMessage();
    }


    sqlsrv_free_stmt($stmt);
    ?>
     

    sdlrs6

    Well-known member
  • Feb 20, 2008
    30,449
    921
    113
    34
    In the Sky
    මන් ගාව code එකක් තිබ්බ.ගෙදර ගියාම දාන්නම්..
    ade thanx machan
    3.gif
     

    sdlrs6

    Well-known member
  • Feb 20, 2008
    30,449
    921
    113
    34
    In the Sky
    <?php

    $serverName = "serverName"; //serverName\instanceName

    // Since UID and PWD are not specified in the $connectionInfo array,
    // The connection will be attempted using Windows Authentication.
    $connectionInfo = array('Database' => 'DB_NAME', "UID" => "DB_UserName", "PWD" => "DB_Password");
    $conn = sqlsrv_connect( $serverName, $connectionInfo);

    if( $conn ) {
    echo "Connection established.<br />";
    }else{
    echo "Connection could not be established.<br />";
    die( print_r( sqlsrv_errors(), true));
    }








    $sql = "SELECT * FROM Your_table_name WHERE EmployeeID='$empno' AND Date BETWEEN '$from' AND '$to' ";
    $stmt = sqlsrv_query($conn, $sql) or die(sqlsrv_error());
    if ($stmt === false) {
    die(print_r(sqlsrv_errors(), true));
    }

    try {
    while ($row = sqlsrv_fetch_array($stmt)) {


    }
    } catch (Exception $ex) {
    echo $ex->getMessage();
    }


    sqlsrv_free_stmt($stmt);
    ?>
    instanceName eka kianne mokakda nbam
     

    sdlrs6

    Well-known member
  • Feb 20, 2008
    30,449
    921
    113
    34
    In the Sky