sqlsrv_connect in 0.67229795455933 seconds
odbc_execute in 1.0757539272308 seconds
test na tym samym sprzęcie, tej samej bazie danych i przy tej samej ilości Insertów
Kod
<?php
/* Connect to the local server using Windows Authentication and
specify the AdventureWorks database as the database in use. */
$time_start = microtime(true);
try {
$serverName = "PRZEMEK-PC\SQLEXPRESS";
$connectionInfo = array( "Database"=>"Aplikacja");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
for ($i = 1; $i < 1000; $i++ ) {
/* Set up the parameterized query. */
$tsql = "INSERT INTO dbo.Reports
(ReportName,
ReportDesc)
VALUES
(?, ?)";
/* Set parameter values. */
$params = array('75123', 'rrr');
/* Prepare and execute the query. */
$stmt = sqlsrv_query( $conn, $tsql, $params);
}
/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
} catch (Exception $e) {
echo $e;
}
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "sqlsrv_connect in $time seconds\n";
echo '<br>';
$time_start = microtime(true);
try {
$conn = odbc_connect("PRZEMEK", "", "") or die('uuuu cha, cha');
for ($i = 1; $i < 1000; $i++ ) {
/* Set up the parameterized query. */
$tsql = "INSERT INTO dbo.Reports
(ReportName,
ReportDesc)
VALUES
(?, ?)";
/* Set parameter values. */
$params = array('75123', 'rrr');
/* Prepare and execute the query. */
#$stmt = sqlsrv_query( $conn, $tsql, $params);
$stmt = odbc_prepare($conn, $tsql);
$success = odbc_execute($stmt, array('75123', 'rrr'));
}
odbc_close($conn);
} catch (Exception $e) {
echo $e;
}
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "odbc_execute in $time seconds\n";
echo '<br>';
?>