$userToDelete = 'Jared' $tsql = 'DELETE FROM TestSchema.Employees WHERE Name = ?' $params = array ( $userToDelete ) $getResults = sqlsrv_query ( $conn, $tsql, $params ) echo ( 'Deleting user '.
PHP_EOL ) sqlsrv_free_stmt ( $getResults ) //Delete Query PHP_EOL ) $getResults = sqlsrv_query ( $conn, $tsql, $params ) $rowsAffected = sqlsrv_rows_affected ( $getResults ) if ( $getResults = FALSE or $rowsAffected = FALSE ) die ( FormatErrors ( sqlsrv_errors ())) echo ( $rowsAffected. $userToUpdate = 'Nikita' $tsql = 'UPDATE TestSchema.Employees SET Location = ? WHERE Name = ?' $params = array ( 'Sweden', $userToUpdate ) echo ( 'Updating Location for user '. PHP_EOL ) sqlsrv_free_stmt ( $getResults ) //Update Query
PHP_EOL ) $tsql = 'INSERT INTO TestSchema.Employees (Name, Location) VALUES (?,?) ' $params = array ( '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. $conn = sqlsrv_connect ( $serverName, $connectionOptions ) //Insert QueryĮcho ( 'Inserting a new row into table'. 'SampleDB', 'Uid' => 'sa', 'PWD' => 'your_password' ) //Establishes the connection