sqlsrv

Backup SQL Server database using PHP

谁说我不能喝 提交于 2021-01-27 18:19:30
问题 I am trying to backup a MS SQL database calling a Stored Procedure using PHP. When I execute de SP on SSMS, everything works fine. However, when I call it from the PHP script, I can see a ".bak" in the backup folder and right after the PHP finishes processing, the BackUp.bak file disappears. Here is the Stored Procedure: DECLARE @date VARCHAR(10) SET @date = (SELECT date FROM tbl_date) Declare @fileName VARCHAR(100) SET @fileName = ('C:\db_backup\BackUp_' + @date + '.bak') BACKUP DATABASE

SQL - Select doesn't retrieve results

会有一股神秘感。 提交于 2020-12-26 11:24:29
问题 I'm using sqlsrv_num_rows in order to check if a user exists in the DB. When i'm running the query in my DB i'm getting 1 result, but in my PHP I'm not getting anything ( echo doesn't print anything). Why is that? $query = "SELECT TOP 1 id, tourOp FROM users WHERE (valid = 1) AND (email = '".trim($_POST['email'])."') AND (password = '".trim($_POST['password'])."')"; $stmt = sqlsrv_query( $conn, $query); echo "num: ".sqlsrv_num_rows( $stmt ); if (!sqlsrv_num_rows( $stmt )) { return (false); }

PHP get return value of stored procedure

喜你入骨 提交于 2020-12-06 07:08:15
问题 I have pleasure to work with legacy PHP application using SQL Server via PDO. How in PHP can I retrieve return value of stored procedure which is using RETURN statement as output channel? Example procedure CREATE PROCEDURE [dbo].[mleko_test] @param INT AS BEGIN RETURN @param * 3; END GO If possible, I would prefer to not modify procedure. I am aware that there are similar questions, but they don't cover this case Get RETURN value from stored procedure in SQL Get Return Value from SQL Stored

PHP get return value of stored procedure

狂风中的少年 提交于 2020-12-06 07:07:42
问题 I have pleasure to work with legacy PHP application using SQL Server via PDO. How in PHP can I retrieve return value of stored procedure which is using RETURN statement as output channel? Example procedure CREATE PROCEDURE [dbo].[mleko_test] @param INT AS BEGIN RETURN @param * 3; END GO If possible, I would prefer to not modify procedure. I am aware that there are similar questions, but they don't cover this case Get RETURN value from stored procedure in SQL Get Return Value from SQL Stored

PHP sqlsrv_connect to SQL Server: A network-related or instance-specific error has occurred while establishing a connection to SQL Server

ⅰ亾dé卋堺 提交于 2020-06-17 03:33:32
问题 I want to connect PHP 7.1 to SQL Server. I add compatible drivers from: https://docs.microsoft.com/en-us/sql/connect/php/microsoft-php-driver-for-sql-server try { $serverName = "tcp:localhost,1433"; $connectionOptions = array("Database" => "fc","Uid" => "sa", "PWD" => "Aa123456"); $conn = sqlsrv_connect($serverName, $connectionOptions); if ($conn == false){ die (print_r(sqlsrv_errors ()));} } catch (Exception $e) { echo("Error!"); } to my php.ini and I checked that in phpinfo() Now I have

Does sqlsrv_query limit the number of statements that can be exectuted in one query?

∥☆過路亽.° 提交于 2020-06-16 17:25:52
问题 I am generating a SQL insert statement within a PHP for loop. The SQL string generated is a large number of individual SQL statements like this: INSERT INTO tbl VALUES(1,2,3); INSERT INTO tbl VALUES(4,5,6); INSERT INTO tbl VALUES(7,8,9); etc... Then I execute with: $InsertResult = sqlsrv_query($conn, $InsertSQL); The problem is that only the first 312 statements get executed instead of the full 2082 lines (only 312 rows are inserted into the table). When I output the $InsertSQL variable to