An example of a basic ODBC (MSSQL Server/DSN-Less) query using PHP.
Example of Result Set Returning One Row
1 2 3 4 5 6 7 8 9 |
$szDBConn="DRIVER={SQL Server};SERVER=SQLServerNameHere;DATABASE=DatabaseNameHere"; $szDBUsername="UsernameHere"; $szDBPswd="PasswordHere"; $szDBQuery="SELECT FooBar, Foo_Bar, Foo_ID FROM FoobarSubscribers WHERE FooID=777"; $rDBConnect = odbc_connect($szDBConn, $szDBUsername, $szDBPswd); $rDBRes = odbc_exec($rDBConnect, $szDBQuery); $szLastCheck = odbc_result($rDBRes, "LastCheck"); odbc_free_result($rDBRes); odbc_close($rDBConnect); |
Example of Result Set Returning Multiple Rows in an Object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$szDBConn="DRIVER={SQL Server};SERVER=SQLServerNameHere;DATABASE=DatabaseNameHere"; $szDBUsername="UsernameHere"; … |