I am doing a PHP app on my Windows PC. I installed XAMPP on my Windows PC and installed MS SQL Server driver for PHP and the PHP pages could communicate with the MS SQL Server database that is also installed on my Windows PC. The connection to the MS SQL Server database is created with pdo sqlsrv as follows:
$conn = new PDO("sqlsrv:server=$serverName ; Database = $dbName", $userName, $userPassword);
$query=' update statement; insert statement; select statement;'; -- can contain multiple SQL statements
$getRes = $conn->prepare($query);
$params=array( if any;);
$getRes->execute($params);
while($row = $getRes->fetch( PDO::FETCH_ASSOC )) {
--display results with echo statements to web page;
}
With pdo sqlsrv, $conn->prepare() can contains multiple SQL Statements at once. It works well on my local PC.
I am testing web hosting from AWS amazon.com. I added LAMP Packaged by Bitnami as an EC2 application on AWS. But I do not know if and how I could install MS SQL Server driver for PHP on amazon.com that is linux 2 (?). But I found the pdo_dblib shipped with LAMP package on AWS can connect to MS SQL Server with the following code:
$conn = new PDO("dblib:host=$serverName;Database=$dbName", $userName, $userPassword);
$getRes = $conn->prepare($query);
$query=' only one statement;';
-- $query can contain no more than one SQL statement, otherwise no result gets returned and with no error message
$params=array( if any;);
$getRes->execute($params);
This one uses pdo_dblib, not pdo_sqlsrv. The problem is this pdo_dblib can only send ONE SQL statement at once, and could not send multiple SQL statements at once, which is different from the above pdo_sqlsrv method that is used on my local Windows PC. To make the php app work, I have to rewrite my queries to include only one SQL statement for each $conn->prepare($query). This is unwanted and I want to know if there is any way to include multiple SQL statements at once with pdo_dblib, or if I could install pdo_sqlsrv in PHP of LAMP Packaged by Bitnami on aws amazon. thank you
I tried pdo_dblib but it can send only ONE sql statement at once which requires to rewrite my queries.
I want to know if there is any way to include multiple SQL statements at once with pdo_dblib, or if I could install pdo_sqlsrv in PHP of LAMP Packaged by Bitnami on aws amazon.