mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Merge pull request #768 from ravage84/code-example-modernization
Code example modernization
This commit is contained in:
@@ -1,63 +1,68 @@
|
||||
<?php
|
||||
echo "\n";
|
||||
$serverName = "tcp:yourserver.database.windows.net,1433";
|
||||
echo "\n";
|
||||
$serverName = 'tcp:your_server.database.windows.net,1433';
|
||||
|
||||
$connectionOptions = array("Database"=>"yourpassword",
|
||||
"Uid"=>"yourusername", "PWD"=>"yourpassword");
|
||||
$connectionOptions = [
|
||||
'Database' => 'your_database',
|
||||
'Uid' => 'your_username',
|
||||
'PWD' => 'your_password',
|
||||
];
|
||||
|
||||
$conn = sqlsrv_connect($serverName, $connectionOptions);
|
||||
$conn = sqlsrv_connect($serverName, $connectionOptions);
|
||||
|
||||
$tsql = "SELECT [CompanyName] FROM SalesLT.Customer";
|
||||
$tsql = 'SELECT [CompanyName] FROM SalesLT.Customer';
|
||||
|
||||
$getProducts = sqlsrv_query($conn, $tsql);
|
||||
$getProducts = sqlsrv_query($conn, $tsql);
|
||||
|
||||
if ($getProducts == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
if ($getProducts === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
|
||||
$productCount = 0;
|
||||
$ctr = 0;
|
||||
while($row = sqlsrv_fetch_array($getProducts, SQLSRV_FETCH_ASSOC))
|
||||
{
|
||||
$ctr++;
|
||||
echo($row['CompanyName']);
|
||||
echo("<br/>");
|
||||
$productCount++;
|
||||
if($ctr>10)
|
||||
break;
|
||||
}
|
||||
$productCount = 0;
|
||||
$ctr = 0;
|
||||
while ($row = sqlsrv_fetch_array($getProducts, SQLSRV_FETCH_ASSOC)) {
|
||||
$ctr++;
|
||||
echo($row['CompanyName']);
|
||||
echo('<br/>');
|
||||
$productCount++;
|
||||
if ($ctr > 10) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sqlsrv_free_stmt($getProducts);
|
||||
sqlsrv_free_stmt($getProducts);
|
||||
|
||||
$tsql = "INSERT SalesLT.Product (Name, ProductNumber, StandardCost, ListPrice, SellStartDate) OUTPUT INSERTED.ProductID VALUES ('SQL Server 15', 'SQL Server 12', 0, 0, getdate())";
|
||||
$tsql = "INSERT SalesLT.Product (Name, ProductNumber, StandardCost, ListPrice, SellStartDate)
|
||||
OUTPUT INSERTED.ProductID
|
||||
VALUES ('SQL Server 15', 'SQL Server 12', 0, 0, getdate());";
|
||||
|
||||
$insertReview = sqlsrv_query($conn, $tsql);
|
||||
if ($insertReview === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
|
||||
$insertReview = sqlsrv_query($conn, $tsql);
|
||||
if($insertReview == FALSE)
|
||||
die(FormatErrors( sqlsrv_errors()));
|
||||
while ($row = sqlsrv_fetch_array($insertReview, SQLSRV_FETCH_ASSOC)) {
|
||||
echo($row['ProductID']);
|
||||
}
|
||||
sqlsrv_free_stmt($insertReview);
|
||||
|
||||
$tsql = 'DELETE FROM [SalesLT].[Product] WHERE Name=?';
|
||||
$params = ['SQL Server 15'];
|
||||
|
||||
while($row = sqlsrv_fetch_array($insertReview, SQLSRV_FETCH_ASSOC))
|
||||
{
|
||||
echo($row['ProductID']);
|
||||
}
|
||||
sqlsrv_free_stmt($insertReview);
|
||||
$deleteReview = sqlsrv_prepare($conn, $tsql, $params);
|
||||
if ($deleteReview === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
|
||||
$tsql = "DELETE FROM [SalesLT].[Product] WHERE Name=?";
|
||||
$params = array("SQL Server 15");
|
||||
|
||||
$deleteReview = sqlsrv_prepare($conn, $tsql, $params);
|
||||
if($deleteReview == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
|
||||
if(sqlsrv_execute($deleteReview) == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
|
||||
while($row = sqlsrv_fetch_array($deleteReview, SQLSRV_FETCH_ASSOC))
|
||||
{
|
||||
echo($row['ProductID']);
|
||||
}
|
||||
sqlsrv_free_stmt($deleteReview);
|
||||
|
||||
|
||||
?>
|
||||
if (sqlsrv_execute($deleteReview) === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
|
||||
while ($row = sqlsrv_fetch_array($deleteReview, SQLSRV_FETCH_ASSOC)) {
|
||||
echo($row['ProductID']);
|
||||
}
|
||||
sqlsrv_free_stmt($deleteReview);
|
||||
|
||||
+143
-122
@@ -1,138 +1,159 @@
|
||||
<?php
|
||||
$serverName = "tcp:yourserver.database.windows.net,1433";
|
||||
$connectionOptions = array("Database"=>"yourdatabase",
|
||||
"Uid"=>"yourusername", "PWD"=>"yourpassword");
|
||||
//Establishes the connection
|
||||
$conn = sqlsrv_connect($serverName, $connectionOptions);
|
||||
//////////////////STORED PROCEDURE/////////////////////////
|
||||
$tsql = "CREATE PROCEDURE sp_GetCompanies22 AS BEGIN SELECT [CompanyName] FROM SalesLT.Customer END";
|
||||
$storedProc = sqlsrv_query($conn, $tsql);
|
||||
if($storedProc == FALSE){
|
||||
echo "Error creating Stored Procedure";
|
||||
die(FormatErrors( sqlsrv_errors()));
|
||||
}
|
||||
sqlsrv_free_stmt($storedProc);
|
||||
|
||||
$tsql = "exec sp_GETCompanies22";
|
||||
//Executes the query
|
||||
$getProducts = sqlsrv_query($conn, $tsql);
|
||||
//Error handling
|
||||
if ($getProducts == FALSE){
|
||||
echo "Error executing Stored Procedure";
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
}
|
||||
$productCount = 0;
|
||||
$ctr = 0;
|
||||
?>
|
||||
<h1> First 10 results are after executing the stored procedure: </h1>
|
||||
<?php
|
||||
while($row = sqlsrv_fetch_array($getProducts, SQLSRV_FETCH_ASSOC)){
|
||||
//Printing only the first 10 results
|
||||
if($ctr>9)
|
||||
break;
|
||||
$ctr++;
|
||||
echo($row['CompanyName']);
|
||||
echo("<br/>");
|
||||
$productCount++;
|
||||
}
|
||||
sqlsrv_free_stmt($getProducts);
|
||||
$tsql = "DROP PROCEDURE sp_GETCompanies22";
|
||||
$serverName = 'tcp:your_server.database.windows.net,1433';
|
||||
$connectionOptions = [
|
||||
'Database' => 'your_database',
|
||||
'Uid' => 'your_username',
|
||||
'PWD' => ' your_password',
|
||||
];
|
||||
// Establishes the connection
|
||||
$conn = sqlsrv_connect($serverName, $connectionOptions);
|
||||
|
||||
$storedProc = sqlsrv_query($conn, $tsql);
|
||||
if($storedProc == FALSE)
|
||||
{
|
||||
echo "Error dropping Stored Procedure";
|
||||
die(FormatErrors( sqlsrv_errors()));
|
||||
}
|
||||
sqlsrv_free_stmt($storedProc);
|
||||
/*
|
||||
* Stored Procedure
|
||||
*/
|
||||
|
||||
$tsql = 'CREATE PROCEDURE sp_GetCompanies22 AS BEGIN SELECT [CompanyName] FROM SalesLT.Customer END';
|
||||
$storedProc = sqlsrv_query($conn, $tsql);
|
||||
if ($storedProc === false) {
|
||||
echo 'Error creating Stored Procedure';
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
sqlsrv_free_stmt($storedProc);
|
||||
|
||||
$tsql = 'exec sp_GETCompanies22';
|
||||
// Executes the query
|
||||
$getProducts = sqlsrv_query($conn, $tsql);
|
||||
// Error handling
|
||||
if ($getProducts === false) {
|
||||
echo 'Error executing Stored Procedure';
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
$productCount = 0;
|
||||
$ctr = 0;
|
||||
?>
|
||||
<h1> First 10 results are after executing the stored procedure: </h1>
|
||||
<?php
|
||||
while ($row = sqlsrv_fetch_array($getProducts, SQLSRV_FETCH_ASSOC)) {
|
||||
// Printing only the first 10 results
|
||||
if ($ctr > 9) {
|
||||
break;
|
||||
}
|
||||
$ctr++;
|
||||
echo($row['CompanyName']);
|
||||
echo('<br/>');
|
||||
$productCount++;
|
||||
}
|
||||
sqlsrv_free_stmt($getProducts);
|
||||
$tsql = 'DROP PROCEDURE sp_GETCompanies22';
|
||||
|
||||
$storedProc = sqlsrv_query($conn, $tsql);
|
||||
if ($storedProc === false) {
|
||||
echo 'Error dropping Stored Procedure';
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
sqlsrv_free_stmt($storedProc);
|
||||
?>
|
||||
<?php
|
||||
//////////////////TRANSACTION/////////////////////////
|
||||
if (sqlsrv_begin_transaction($conn) == FALSE)
|
||||
{
|
||||
echo "Error opening connection";
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
}
|
||||
/*
|
||||
* Transaction
|
||||
*/
|
||||
|
||||
/* Set up and execute the first query. */
|
||||
$tsql1 = "INSERT INTO SalesLT.SalesOrderDetail
|
||||
if (sqlsrv_begin_transaction($conn) === false) {
|
||||
echo 'Error opening connection';
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
|
||||
/* Set up and execute the first query. */
|
||||
$tsql1 = 'INSERT INTO SalesLT.SalesOrderDetail
|
||||
(SalesOrderID,OrderQty,ProductID,UnitPrice)
|
||||
VALUES (71774, 22, 709, 33)";
|
||||
$stmt1 = sqlsrv_query($conn, $tsql1);
|
||||
VALUES (71774, 22, 709, 33)';
|
||||
$stmt1 = sqlsrv_query($conn, $tsql1);
|
||||
|
||||
/* Set up and execute the second query. */
|
||||
$tsql2 = "UPDATE SalesLT.SalesOrderDetail SET OrderQty = (OrderQty + 1) WHERE ProductID = 709";
|
||||
$stmt2 = sqlsrv_query( $conn, $tsql2);
|
||||
/* Set up and execute the second query. */
|
||||
$tsql2 = 'UPDATE SalesLT.SalesOrderDetail SET OrderQty = (OrderQty + 1) WHERE ProductID = 709';
|
||||
$stmt2 = sqlsrv_query($conn, $tsql2);
|
||||
|
||||
/* If both queries were successful, commit the transaction. */
|
||||
/* Otherwise, rollback the transaction. */
|
||||
if($stmt1 && $stmt2)
|
||||
{
|
||||
sqlsrv_commit($conn);
|
||||
?>
|
||||
<h1> Transaction was commited </h1>
|
||||
/* If both queries were successful, commit the transaction. */
|
||||
/* Otherwise, rollback the transaction. */
|
||||
if ($stmt1 && $stmt2) {
|
||||
sqlsrv_commit($conn);
|
||||
?>
|
||||
<h1> Transaction was committed </h1>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlsrv_rollback($conn);
|
||||
echo "Transaction was rolled back.\n";
|
||||
}
|
||||
<?php
|
||||
} else {
|
||||
sqlsrv_rollback($conn);
|
||||
echo "Transaction was rolled back.\n";
|
||||
}
|
||||
|
||||
/* Free statement and connection resources. */
|
||||
sqlsrv_free_stmt( $stmt1);
|
||||
sqlsrv_free_stmt( $stmt2);
|
||||
/* Free statement and connection resources. */
|
||||
sqlsrv_free_stmt($stmt1);
|
||||
sqlsrv_free_stmt($stmt2);
|
||||
|
||||
?>
|
||||
<?php
|
||||
//////////////////UDF/////////////////////////
|
||||
//Dropping function if it already exists
|
||||
$tsql1 = "IF OBJECT_ID(N'dbo.ifGetTotalItems', N'IF') IS NOT NULL DROP FUNCTION dbo.ifGetTotalItems;";
|
||||
$getProducts = sqlsrv_query($conn, $tsql1);
|
||||
//Error handling
|
||||
if ($getProducts == FALSE)
|
||||
{
|
||||
echo "Error deleting the UDF";
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
}
|
||||
$tsql1 = "CREATE FUNCTION dbo.ifGetTotalItems (@OrderID INT) RETURNS TABLE WITH SCHEMABINDING AS RETURN (SELECT SUM(OrderQty) AS TotalItems FROM SalesLT.SalesOrderDetail WHERE SalesOrderID = @OrderID GROUP BY SalesOrderID);";
|
||||
$getProducts = sqlsrv_query($conn, $tsql1);
|
||||
//Error handling
|
||||
if ($getProducts == FALSE)
|
||||
{
|
||||
echo "Error creating the UDF";
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
}
|
||||
$tsql1 = "SELECT s.SalesOrderID, s.OrderDate, s.CustomerID, f.TotalItems FROM SalesLT.SalesOrderHeader s CROSS APPLY dbo.ifGetTotalItems(s.SalesOrderID) f ORDER BY SalesOrderID;";
|
||||
$getProducts = sqlsrv_query($conn, $tsql1);
|
||||
//Error handling
|
||||
if ($getProducts == FALSE)
|
||||
{
|
||||
echo "Error executing the UDF";
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
}
|
||||
$productCount = 0;
|
||||
$ctr = 0;
|
||||
?>
|
||||
<h1> First 10 results are after executing a query that uses the UDF: </h1>
|
||||
/*
|
||||
* UDF
|
||||
*/
|
||||
// Dropping function if it already exists
|
||||
$tsql1 = "IF OBJECT_ID(N'dbo.ifGetTotalItems', N'IF') IS NOT NULL DROP FUNCTION dbo.ifGetTotalItems;";
|
||||
$getProducts = sqlsrv_query($conn, $tsql1);
|
||||
// Error handling
|
||||
if ($getProducts === false) {
|
||||
echo 'Error deleting the UDF';
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
$tsql1 = 'CREATE FUNCTION dbo.ifGetTotalItems (@OrderID INT) RETURNS TABLE WITH SCHEMABINDING AS RETURN (
|
||||
SELECT SUM(OrderQty) AS TotalItems FROM SalesLT.SalesOrderDetail
|
||||
WHERE SalesOrderID = @OrderID
|
||||
GROUP BY SalesOrderID
|
||||
);';
|
||||
$getProducts = sqlsrv_query($conn, $tsql1);
|
||||
// Error handling
|
||||
if ($getProducts === false) {
|
||||
echo 'Error creating the UDF';
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
$tsql1 = 'SELECT s.SalesOrderID, s.OrderDate, s.CustomerID, f.TotalItems
|
||||
FROM SalesLT.SalesOrderHeader s
|
||||
CROSS APPLY dbo.ifGetTotalItems(s.SalesOrderID) f
|
||||
ORDER BY SalesOrderID;';
|
||||
$getProducts = sqlsrv_query($conn, $tsql1);
|
||||
// Error handling
|
||||
if ($getProducts === false) {
|
||||
echo 'Error executing the UDF';
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
$productCount = 0;
|
||||
$ctr = 0;
|
||||
?>
|
||||
<h1> First 10 results are after executing a query that uses the UDF: </h1>
|
||||
<?php
|
||||
echo "SalesOrderID CustomerID TotalItems";
|
||||
echo("<br/>");
|
||||
echo 'SalesOrderID CustomerID TotalItems';
|
||||
echo('<br/>');
|
||||
|
||||
while($row = sqlsrv_fetch_array($getProducts, SQLSRV_FETCH_ASSOC))
|
||||
{
|
||||
//Printing only the top 10 results
|
||||
if($ctr>9)
|
||||
break;
|
||||
$ctr++;
|
||||
echo $row['SalesOrderID'] . str_repeat(' ', 13) . $row['CustomerID'] . str_repeat(' ', 11) . $row['TotalItems'];
|
||||
echo("<br/>");
|
||||
$productCount++;
|
||||
|
||||
while ($row = sqlsrv_fetch_array($getProducts, SQLSRV_FETCH_ASSOC)) {
|
||||
// Printing only the top 10 results
|
||||
if ($ctr > 9) {
|
||||
break;
|
||||
}
|
||||
sqlsrv_free_stmt($getProducts);
|
||||
|
||||
|
||||
?>
|
||||
$ctr++;
|
||||
echo sprintf(
|
||||
'%s%s%s%s%s',
|
||||
$row['SalesOrderID'],
|
||||
str_repeat(' ', 13),
|
||||
$row['CustomerID'],
|
||||
str_repeat(' ', 11),
|
||||
$row['TotalItems']
|
||||
);
|
||||
echo('<br/>');
|
||||
$productCount++;
|
||||
}
|
||||
sqlsrv_free_stmt($getProducts);
|
||||
|
||||
@@ -1,42 +1,40 @@
|
||||
<?php
|
||||
$time_start = microtime(true);
|
||||
$timeStart = microtime(true);
|
||||
|
||||
$serverName = "localhost";
|
||||
$connectionOptions = array(
|
||||
"Database" => "SampleDB",
|
||||
"Uid" => "sa",
|
||||
"PWD" => "your_password"
|
||||
);
|
||||
//Establishes the connection
|
||||
$serverName = 'localhost';
|
||||
$connectionOptions = [
|
||||
'Database' => 'SampleDB',
|
||||
'Uid' => 'sa',
|
||||
'PWD' => 'your_password',
|
||||
];
|
||||
// Establishes the connection
|
||||
$conn = sqlsrv_connect($serverName, $connectionOptions);
|
||||
|
||||
//Read Query
|
||||
$tsql= "SELECT SUM(Price) as sum FROM Table_with_5M_rows";
|
||||
$getResults= sqlsrv_query($conn, $tsql);
|
||||
echo ("Sum: ");
|
||||
if ($getResults == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
// Read Query
|
||||
$tsql = 'SELECT SUM(Price) as sum FROM Table_with_5M_rows';
|
||||
$getResults = sqlsrv_query($conn, $tsql);
|
||||
echo('Sum: ');
|
||||
if ($getResults === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
|
||||
echo ($row['sum'] . PHP_EOL);
|
||||
|
||||
echo($row['sum'] . PHP_EOL);
|
||||
}
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
function FormatErrors( $errors )
|
||||
function format_errors($errors)
|
||||
{
|
||||
/* Display errors. */
|
||||
echo "Error information: ";
|
||||
echo 'Error information: ';
|
||||
|
||||
foreach ( $errors as $error )
|
||||
{
|
||||
echo "SQLSTATE: ".$error['SQLSTATE']."";
|
||||
echo "Code: ".$error['code']."";
|
||||
echo "Message: ".$error['message']."";
|
||||
foreach ($errors as $error) {
|
||||
echo 'SQLSTATE: ' . $error['SQLSTATE'] . '';
|
||||
echo 'Code: ' . $error['code'] . '';
|
||||
echo 'Message: ' . $error['message'] . '';
|
||||
}
|
||||
}
|
||||
$time_end = microtime(true);
|
||||
$execution_time = round((($time_end - $time_start)*1000),2);
|
||||
echo 'QueryTime: '.$execution_time.' ms';
|
||||
|
||||
|
||||
?>
|
||||
$timeEnd = microtime(true);
|
||||
$executionTime = round((($timeEnd - $timeStart) * 1000), 2);
|
||||
echo 'QueryTime: ' . $executionTime . ' ms';
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
$serverName = "localhost";
|
||||
$connectionOptions = array(
|
||||
"Database" => "SampleDB",
|
||||
"Uid" => "sa",
|
||||
"PWD" => "your_password"
|
||||
);
|
||||
//Establishes the connection
|
||||
$serverName = 'localhost';
|
||||
$connectionOptions = [
|
||||
'Database' => 'SampleDB',
|
||||
'Uid' => 'sa',
|
||||
'PWD' => 'your_password',
|
||||
];
|
||||
// Establishes the connection
|
||||
$conn = sqlsrv_connect($serverName, $connectionOptions);
|
||||
if($conn)
|
||||
echo "Connected!"
|
||||
?>
|
||||
if ($conn) {
|
||||
echo 'Connected!';
|
||||
}
|
||||
|
||||
@@ -1,74 +1,78 @@
|
||||
<?php
|
||||
$serverName = "localhost";
|
||||
$connectionOptions = array(
|
||||
"Database" => "SampleDB",
|
||||
"Uid" => "sa",
|
||||
"PWD" => "your_password"
|
||||
);
|
||||
//Establishes the connection
|
||||
$serverName = 'localhost';
|
||||
$connectionOptions = [
|
||||
'Database' => 'SampleDB',
|
||||
'Uid' => 'sa',
|
||||
'PWD' => 'your_password',
|
||||
];
|
||||
// Establishes the connection
|
||||
$conn = sqlsrv_connect($serverName, $connectionOptions);
|
||||
|
||||
//Insert Query
|
||||
echo ("Inserting a new row into table" . PHP_EOL);
|
||||
$tsql= "INSERT INTO TestSchema.Employees (Name, Location) VALUES (?,?);";
|
||||
$params = array('Jake','United States');
|
||||
$getResults= sqlsrv_query($conn, $tsql, $params);
|
||||
// Insert Query
|
||||
echo('Inserting a new row into table' . PHP_EOL);
|
||||
$tsql = 'INSERT INTO TestSchema.Employees (Name, Location) VALUES (?,?);';
|
||||
$params = ['Jake', 'United States'];
|
||||
$getResults = sqlsrv_query($conn, $tsql, $params);
|
||||
$rowsAffected = sqlsrv_rows_affected($getResults);
|
||||
if ($getResults == FALSE or $rowsAffected == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
echo ($rowsAffected. " row(s) inserted: " . PHP_EOL);
|
||||
if ($getResults === false || $rowsAffected === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
echo($rowsAffected . ' row(s) inserted: ' . PHP_EOL);
|
||||
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
//Update Query
|
||||
// Update Query
|
||||
|
||||
$userToUpdate = 'Nikita';
|
||||
$tsql= "UPDATE TestSchema.Employees SET Location = ? WHERE Name = ?";
|
||||
$params = array('Sweeden', $userToUpdate);
|
||||
echo("Updating Location for user " . $userToUpdate . PHP_EOL);
|
||||
$tsql = 'UPDATE TestSchema.Employees SET Location = ? WHERE Name = ?';
|
||||
$params = ['Sweden', $userToUpdate];
|
||||
echo('Updating Location for user ' . $userToUpdate . PHP_EOL);
|
||||
|
||||
$getResults= sqlsrv_query($conn, $tsql, $params);
|
||||
$getResults = sqlsrv_query($conn, $tsql, $params);
|
||||
$rowsAffected = sqlsrv_rows_affected($getResults);
|
||||
if ($getResults == FALSE or $rowsAffected == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
echo ($rowsAffected. " row(s) updated: " . PHP_EOL);
|
||||
if ($getResults === false || $rowsAffected === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
echo($rowsAffected . ' row(s) updated: ' . PHP_EOL);
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
//Delte Query
|
||||
// Delete Query
|
||||
$userToDelete = 'Jared';
|
||||
$tsql= "DELETE FROM TestSchema.Employees WHERE Name = ?";
|
||||
$params = array($userToDelete);
|
||||
$getResults= sqlsrv_query($conn, $tsql, $params);
|
||||
echo("Deleting user " . $userToDelete . PHP_EOL);
|
||||
$tsql = 'DELETE FROM TestSchema.Employees WHERE Name = ?';
|
||||
$params = [$userToDelete];
|
||||
$getResults = sqlsrv_query($conn, $tsql, $params);
|
||||
echo('Deleting user ' . $userToDelete . PHP_EOL);
|
||||
$rowsAffected = sqlsrv_rows_affected($getResults);
|
||||
if ($getResults == FALSE or $rowsAffected == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
echo ($rowsAffected. " row(s) deleted: " . PHP_EOL);
|
||||
if ($getResults === false || $rowsAffected === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
echo($rowsAffected . ' row(s) deleted: ' . PHP_EOL);
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
|
||||
//Read Query
|
||||
$tsql= "SELECT Id, Name, Location FROM TestSchema.Employees;";
|
||||
$getResults= sqlsrv_query($conn, $tsql);
|
||||
echo ("Reading data from table" . PHP_EOL);
|
||||
if ($getResults == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
// Read Query
|
||||
$tsql = 'SELECT Id, Name, Location FROM TestSchema.Employees;';
|
||||
$getResults = sqlsrv_query($conn, $tsql);
|
||||
echo('Reading data from table' . PHP_EOL);
|
||||
if ($getResults === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
|
||||
echo ($row['Id'] . " " . $row['Name'] . " " . $row['Location'] . PHP_EOL);
|
||||
|
||||
echo($row['Id'] . ' ' . $row['Name'] . ' ' . $row['Location'] . PHP_EOL);
|
||||
}
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
function FormatErrors( $errors )
|
||||
function format_errors($errors)
|
||||
{
|
||||
/* Display errors. */
|
||||
echo "Error information: ";
|
||||
echo 'Error information: ';
|
||||
|
||||
foreach ( $errors as $error )
|
||||
{
|
||||
echo "SQLSTATE: ".$error['SQLSTATE']."";
|
||||
echo "Code: ".$error['code']."";
|
||||
echo "Message: ".$error['message']."";
|
||||
foreach ($errors as $error) {
|
||||
echo 'SQLSTATE: ' . $error['SQLSTATE'] . '';
|
||||
echo 'Code: ' . $error['code'] . '';
|
||||
echo 'Message: ' . $error['message'] . '';
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,42 +1,40 @@
|
||||
<?php
|
||||
$time_start = microtime(true);
|
||||
$timeStart = microtime(true);
|
||||
|
||||
$serverName = "localhost";
|
||||
$connectionOptions = array(
|
||||
"Database" => "SampleDB",
|
||||
"Uid" => "sa",
|
||||
"PWD" => "your_password"
|
||||
);
|
||||
//Establishes the connection
|
||||
$serverName = 'localhost';
|
||||
$connectionOptions = [
|
||||
'Database' => 'SampleDB',
|
||||
'Uid' => 'sa',
|
||||
'PWD' => 'your_password',
|
||||
];
|
||||
// Establishes the connection
|
||||
$conn = sqlsrv_connect($serverName, $connectionOptions);
|
||||
|
||||
//Read Query
|
||||
$tsql= "SELECT SUM(Price) as sum FROM Table_with_5M_rows";
|
||||
$getResults= sqlsrv_query($conn, $tsql);
|
||||
echo ("Sum: ");
|
||||
if ($getResults == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
// Read Query
|
||||
$tsql = 'SELECT SUM(Price) as sum FROM Table_with_5M_rows';
|
||||
$getResults = sqlsrv_query($conn, $tsql);
|
||||
echo('Sum: ');
|
||||
if ($getResults === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
|
||||
echo ($row['sum'] . PHP_EOL);
|
||||
|
||||
echo($row['sum'] . PHP_EOL);
|
||||
}
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
function FormatErrors( $errors )
|
||||
function format_errors($errors)
|
||||
{
|
||||
/* Display errors. */
|
||||
echo "Error information: ";
|
||||
echo 'Error information: ';
|
||||
|
||||
foreach ( $errors as $error )
|
||||
{
|
||||
echo "SQLSTATE: ".$error['SQLSTATE']."";
|
||||
echo "Code: ".$error['code']."";
|
||||
echo "Message: ".$error['message']."";
|
||||
foreach ($errors as $error) {
|
||||
echo 'SQLSTATE: ' . $error['SQLSTATE'] . '';
|
||||
echo 'Code: ' . $error['code'] . '';
|
||||
echo 'Message: ' . $error['message'] . '';
|
||||
}
|
||||
}
|
||||
$time_end = microtime(true);
|
||||
$execution_time = round((($time_end - $time_start)*1000),2);
|
||||
echo 'QueryTime: '.$execution_time.' ms';
|
||||
|
||||
|
||||
?>
|
||||
$timeEnd = microtime(true);
|
||||
$executionTime = round((($timeEnd - $timeStart) * 1000), 2);
|
||||
echo 'QueryTime: ' . $executionTime . ' ms';
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?php
|
||||
// Setup the connection
|
||||
$serverName = "localhost";
|
||||
$serverName = 'localhost';
|
||||
$connectionOptions = [
|
||||
"Database" => "SampleDB",
|
||||
"Uid" => "sa",
|
||||
"PWD" => "your_password"
|
||||
'Database' => 'SampleDB',
|
||||
'Uid' => 'sa',
|
||||
'PWD' => 'your_password'
|
||||
];
|
||||
|
||||
// Establish the connection
|
||||
$connection = sqlsrv_connect($serverName, $connectionOptions);
|
||||
if ($connection) {
|
||||
echo "Connected!";
|
||||
echo 'Connected!';
|
||||
}
|
||||
|
||||
@@ -1,74 +1,78 @@
|
||||
<?php
|
||||
$serverName = "localhost";
|
||||
$connectionOptions = array(
|
||||
"Database" => "SampleDB",
|
||||
"Uid" => "sa",
|
||||
"PWD" => "your_password"
|
||||
);
|
||||
//Establishes the connection
|
||||
$serverName = 'localhost';
|
||||
$connectionOptions = [
|
||||
'Database' => 'SampleDB',
|
||||
'Uid' => 'sa',
|
||||
'PWD' => 'your_password',
|
||||
];
|
||||
// Establishes the connection
|
||||
$conn = sqlsrv_connect($serverName, $connectionOptions);
|
||||
|
||||
//Insert Query
|
||||
echo ("Inserting a new row into table" . PHP_EOL);
|
||||
$tsql= "INSERT INTO TestSchema.Employees (Name, Location) VALUES (?,?);";
|
||||
$params = array('Jake','United States');
|
||||
$getResults= sqlsrv_query($conn, $tsql, $params);
|
||||
// Insert Query
|
||||
echo('Inserting a new row into table' . PHP_EOL);
|
||||
$tsql = 'INSERT INTO TestSchema.Employees (Name, Location) VALUES (?,?);';
|
||||
$params = ['Jake', 'United States'];
|
||||
$getResults = sqlsrv_query($conn, $tsql, $params);
|
||||
$rowsAffected = sqlsrv_rows_affected($getResults);
|
||||
if ($getResults == FALSE or $rowsAffected == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
echo ($rowsAffected. " row(s) inserted: " . PHP_EOL);
|
||||
if ($getResults === false || $rowsAffected === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
echo($rowsAffected . ' row(s) inserted: ' . PHP_EOL);
|
||||
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
//Update Query
|
||||
// Update Query
|
||||
|
||||
$userToUpdate = 'Nikita';
|
||||
$tsql= "UPDATE TestSchema.Employees SET Location = ? WHERE Name = ?";
|
||||
$params = array('Sweeden', $userToUpdate);
|
||||
echo("Updating Location for user " . $userToUpdate . PHP_EOL);
|
||||
$tsql = 'UPDATE TestSchema.Employees SET Location = ? WHERE Name = ?';
|
||||
$params = ['Sweden', $userToUpdate];
|
||||
echo('Updating Location for user ' . $userToUpdate . PHP_EOL);
|
||||
|
||||
$getResults= sqlsrv_query($conn, $tsql, $params);
|
||||
$getResults = sqlsrv_query($conn, $tsql, $params);
|
||||
$rowsAffected = sqlsrv_rows_affected($getResults);
|
||||
if ($getResults == FALSE or $rowsAffected == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
echo ($rowsAffected. " row(s) updated: " . PHP_EOL);
|
||||
if ($getResults === false || $rowsAffected === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
echo($rowsAffected . ' row(s) updated: ' . PHP_EOL);
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
//Delte Query
|
||||
// Delete Query
|
||||
$userToDelete = 'Jared';
|
||||
$tsql= "DELETE FROM TestSchema.Employees WHERE Name = ?";
|
||||
$params = array($userToDelete);
|
||||
$getResults= sqlsrv_query($conn, $tsql, $params);
|
||||
echo("Deleting user " . $userToDelete . PHP_EOL);
|
||||
$tsql = 'DELETE FROM TestSchema.Employees WHERE Name = ?';
|
||||
$params = [$userToDelete];
|
||||
$getResults = sqlsrv_query($conn, $tsql, $params);
|
||||
echo('Deleting user ' . $userToDelete . PHP_EOL);
|
||||
$rowsAffected = sqlsrv_rows_affected($getResults);
|
||||
if ($getResults == FALSE or $rowsAffected == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
echo ($rowsAffected. " row(s) deleted: " . PHP_EOL);
|
||||
if ($getResults === false || $rowsAffected === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
echo($rowsAffected . ' row(s) deleted: ' . PHP_EOL);
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
|
||||
//Read Query
|
||||
$tsql= "SELECT Id, Name, Location FROM TestSchema.Employees;";
|
||||
$getResults= sqlsrv_query($conn, $tsql);
|
||||
echo ("Reading data from table" . PHP_EOL);
|
||||
if ($getResults == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
// Read Query
|
||||
$tsql = 'SELECT Id, Name, Location FROM TestSchema.Employees;';
|
||||
$getResults = sqlsrv_query($conn, $tsql);
|
||||
echo('Reading data from table' . PHP_EOL);
|
||||
if ($getResults === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
|
||||
echo ($row['Id'] . " " . $row['Name'] . " " . $row['Location'] . PHP_EOL);
|
||||
|
||||
echo($row['Id'] . ' ' . $row['Name'] . ' ' . $row['Location'] . PHP_EOL);
|
||||
}
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
function FormatErrors( $errors )
|
||||
function format_errors($errors)
|
||||
{
|
||||
/* Display errors. */
|
||||
echo "Error information: ";
|
||||
echo 'Error information: ';
|
||||
|
||||
foreach ( $errors as $error )
|
||||
{
|
||||
echo "SQLSTATE: ".$error['SQLSTATE']."";
|
||||
echo "Code: ".$error['code']."";
|
||||
echo "Message: ".$error['message']."";
|
||||
foreach ($errors as $error) {
|
||||
echo 'SQLSTATE: ' . $error['SQLSTATE'] . '';
|
||||
echo 'Code: ' . $error['code'] . '';
|
||||
echo 'Message: ' . $error['message'] . '';
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,42 +1,40 @@
|
||||
<?php
|
||||
$time_start = microtime(true);
|
||||
$timeStart = microtime(true);
|
||||
|
||||
$serverName = "localhost";
|
||||
$connectionOptions = array(
|
||||
"Database" => "SampleDB",
|
||||
"Uid" => "sa",
|
||||
"PWD" => "your_password"
|
||||
);
|
||||
//Establishes the connection
|
||||
$serverName = 'localhost';
|
||||
$connectionOptions = [
|
||||
'Database' => 'SampleDB',
|
||||
'Uid' => 'sa',
|
||||
'PWD' => 'your_password',
|
||||
];
|
||||
// Establishes the connection
|
||||
$conn = sqlsrv_connect($serverName, $connectionOptions);
|
||||
|
||||
//Read Query
|
||||
$tsql= "SELECT SUM(Price) as sum FROM Table_with_5M_rows";
|
||||
$getResults= sqlsrv_query($conn, $tsql);
|
||||
echo ("Sum: ");
|
||||
if ($getResults == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
// Read Query
|
||||
$tsql = 'SELECT SUM(Price) as sum FROM Table_with_5M_rows';
|
||||
$getResults = sqlsrv_query($conn, $tsql);
|
||||
echo('Sum: ');
|
||||
if ($getResults === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
|
||||
echo ($row['sum'] . PHP_EOL);
|
||||
|
||||
echo($row['sum'] . PHP_EOL);
|
||||
}
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
function FormatErrors( $errors )
|
||||
function format_errors($errors)
|
||||
{
|
||||
/* Display errors. */
|
||||
echo "Error information: ";
|
||||
echo 'Error information: ';
|
||||
|
||||
foreach ( $errors as $error )
|
||||
{
|
||||
echo "SQLSTATE: ".$error['SQLSTATE']."";
|
||||
echo "Code: ".$error['code']."";
|
||||
echo "Message: ".$error['message']."";
|
||||
foreach ($errors as $error) {
|
||||
echo 'SQLSTATE: ' . $error['SQLSTATE'] . '';
|
||||
echo 'Code: ' . $error['code'] . '';
|
||||
echo 'Message: ' . $error['message'] . '';
|
||||
}
|
||||
}
|
||||
$time_end = microtime(true);
|
||||
$execution_time = round((($time_end - $time_start)*1000),2);
|
||||
echo 'QueryTime: '.$execution_time.' ms';
|
||||
|
||||
|
||||
?>
|
||||
$timeEnd = microtime(true);
|
||||
$executionTime = round((($timeEnd - $timeStart) * 1000), 2);
|
||||
echo 'QueryTime: ' . $executionTime . ' ms';
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
$serverName = "localhost";
|
||||
$connectionOptions = array(
|
||||
"Database" => "SampleDB",
|
||||
"Uid" => "sa",
|
||||
"PWD" => "your_password"
|
||||
);
|
||||
//Establishes the connection
|
||||
$serverName = 'localhost';
|
||||
$connectionOptions = [
|
||||
'Database' => 'SampleDB',
|
||||
'Uid' => 'sa',
|
||||
'PWD' => 'your_password',
|
||||
];
|
||||
// Establishes the connection
|
||||
$conn = sqlsrv_connect($serverName, $connectionOptions);
|
||||
if($conn)
|
||||
echo "Connected!"
|
||||
?>
|
||||
if ($conn) {
|
||||
echo 'Connected!';
|
||||
}
|
||||
|
||||
@@ -1,74 +1,78 @@
|
||||
<?php
|
||||
$serverName = "localhost";
|
||||
$connectionOptions = array(
|
||||
"Database" => "SampleDB",
|
||||
"Uid" => "sa",
|
||||
"PWD" => "your_password"
|
||||
);
|
||||
//Establishes the connection
|
||||
$serverName = 'localhost';
|
||||
$connectionOptions = [
|
||||
'Database' => 'SampleDB',
|
||||
'Uid' => 'sa',
|
||||
'PWD' => 'your_password',
|
||||
];
|
||||
// Establishes the connection
|
||||
$conn = sqlsrv_connect($serverName, $connectionOptions);
|
||||
|
||||
//Insert Query
|
||||
echo ("Inserting a new row into table" . PHP_EOL);
|
||||
$tsql= "INSERT INTO TestSchema.Employees (Name, Location) VALUES (?,?);";
|
||||
$params = array('Jake','United States');
|
||||
$getResults= sqlsrv_query($conn, $tsql, $params);
|
||||
// Insert Query
|
||||
echo('Inserting a new row into table' . PHP_EOL);
|
||||
$tsql = 'INSERT INTO TestSchema.Employees (Name, Location) VALUES (?,?);';
|
||||
$params = ['Jake', 'United States'];
|
||||
$getResults = sqlsrv_query($conn, $tsql, $params);
|
||||
$rowsAffected = sqlsrv_rows_affected($getResults);
|
||||
if ($getResults == FALSE or $rowsAffected == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
echo ($rowsAffected. " row(s) inserted: " . PHP_EOL);
|
||||
if ($getResults === false || $rowsAffected === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
echo($rowsAffected . ' row(s) inserted: ' . PHP_EOL);
|
||||
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
//Update Query
|
||||
// Update Query
|
||||
|
||||
$userToUpdate = 'Nikita';
|
||||
$tsql= "UPDATE TestSchema.Employees SET Location = ? WHERE Name = ?";
|
||||
$params = array('Sweeden', $userToUpdate);
|
||||
echo("Updating Location for user " . $userToUpdate . PHP_EOL);
|
||||
$tsql = 'UPDATE TestSchema.Employees SET Location = ? WHERE Name = ?';
|
||||
$params = ['Sweden', $userToUpdate];
|
||||
echo('Updating Location for user ' . $userToUpdate . PHP_EOL);
|
||||
|
||||
$getResults= sqlsrv_query($conn, $tsql, $params);
|
||||
$getResults = sqlsrv_query($conn, $tsql, $params);
|
||||
$rowsAffected = sqlsrv_rows_affected($getResults);
|
||||
if ($getResults == FALSE or $rowsAffected == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
echo ($rowsAffected. " row(s) updated: " . PHP_EOL);
|
||||
if ($getResults === false || $rowsAffected === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
echo($rowsAffected . ' row(s) updated: ' . PHP_EOL);
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
//Delete Query
|
||||
// Delete Query
|
||||
$userToDelete = 'Jared';
|
||||
$tsql= "DELETE FROM TestSchema.Employees WHERE Name = ?";
|
||||
$params = array($userToDelete);
|
||||
$getResults= sqlsrv_query($conn, $tsql, $params);
|
||||
echo("Deleting user " . $userToDelete . PHP_EOL);
|
||||
$tsql = 'DELETE FROM TestSchema.Employees WHERE Name = ?';
|
||||
$params = [$userToDelete];
|
||||
$getResults = sqlsrv_query($conn, $tsql, $params);
|
||||
echo('Deleting user ' . $userToDelete . PHP_EOL);
|
||||
$rowsAffected = sqlsrv_rows_affected($getResults);
|
||||
if ($getResults == FALSE or $rowsAffected == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
echo ($rowsAffected. " row(s) deleted: " . PHP_EOL);
|
||||
if ($getResults === false || $rowsAffected === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
echo($rowsAffected . ' row(s) deleted: ' . PHP_EOL);
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
|
||||
//Read Query
|
||||
$tsql= "SELECT Id, Name, Location FROM TestSchema.Employees;";
|
||||
$getResults= sqlsrv_query($conn, $tsql);
|
||||
echo ("Reading data from table" . PHP_EOL);
|
||||
if ($getResults == FALSE)
|
||||
die(FormatErrors(sqlsrv_errors()));
|
||||
// Read Query
|
||||
$tsql = 'SELECT Id, Name, Location FROM TestSchema.Employees;';
|
||||
$getResults = sqlsrv_query($conn, $tsql);
|
||||
echo('Reading data from table' . PHP_EOL);
|
||||
if ($getResults === false) {
|
||||
format_errors(sqlsrv_errors());
|
||||
die();
|
||||
}
|
||||
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
|
||||
echo ($row['Id'] . " " . $row['Name'] . " " . $row['Location'] . PHP_EOL);
|
||||
|
||||
echo($row['Id'] . ' ' . $row['Name'] . ' ' . $row['Location'] . PHP_EOL);
|
||||
}
|
||||
sqlsrv_free_stmt($getResults);
|
||||
|
||||
function FormatErrors( $errors )
|
||||
function format_errors($errors)
|
||||
{
|
||||
/* Display errors. */
|
||||
echo "Error information: ";
|
||||
echo 'Error information: ';
|
||||
|
||||
foreach ( $errors as $error )
|
||||
{
|
||||
echo "SQLSTATE: ".$error['SQLSTATE']."";
|
||||
echo "Code: ".$error['code']."";
|
||||
echo "Message: ".$error['message']."";
|
||||
foreach ($errors as $error) {
|
||||
echo 'SQLSTATE: ' . $error['SQLSTATE'] . '';
|
||||
echo 'Code: ' . $error['code'] . '';
|
||||
echo 'Message: ' . $error['message'] . '';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user