Tag: php

Laravel MSSQL Adhoc queries instead of prepared

We are using MSSQL in combination with Laravel which uses the dblib PDO library from PHP. I’ve looked in the illuminate database part and see that it uses the PDO->prepare($query)->execute($bindings). So I am expecting that it would execute a prepared statement at the SQL database. But when I check the table to analyse the queries […]

MSSQL procedure query return “Cannot insert the value NULL into column”

I have a form of 5 fields. when click on submit button it will fetch Amount against the fields from database MSSQL. Now when i fill form and submit it is giving an error. i have used MSSQL procedure query to execute it. please help me out i am in trouble now. <div id=”middle_pane”> <div> […]

PHP Laravel Adaptive Server connection failed (severity 9)

I’m trying to use MsSQL with my Laravel project. But when I execute the select query. [Illuminate\Database\QueryException] SQLSTATE[01002] Adaptive Server connection failed (severity 9) (SQL: exec sp_EntityFullList) [Doctrine\DBAL\Driver\PDOException] SQLSTATE[01002] Adaptive Server connection failed (severity 9) [PDOException] SQLSTATE[01002] Adaptive Server connection failed (severity 9) $db = DB::connection(‘sqlsrv’); print_r($db->select(‘exec sp_EntityFullList’)->disableQueryLog()); Also I can connect the database with […]

sqlsrv_query returns false without any error (sqlsrv_errors())

We have to execute an MSSQL stored procedure in order to insert a set of rows and return the result. The procedure is working perfectly as intended when executed inside the Microsoft SQL Server Management Studio. But it’s not working when executed with sqlsrv_execute or sqlsrv_query in PHP. It’s inserting only one row and returning […]

SQL Server PHP Code Igniter show one to many relationship

i want to show data from table_one,where tableone_id is included on table_two..which is one to many relationship..here is the example. table_one table_two id | name id | name |tableone_id 1 | A 1 | C | 1 2 | B 2 | D | 1 3 | E | 2 4 | F | 2 […]

Dynamic mssql_bind invalid type

Attempting to create a function to type less code for mssql_bind I wish to use this 2d array: Array ( [0] => Array ( [0] => SIZECODENO [1] => SQLVARCHAR ) [1] => Array ( [0] => SIZECODE [1] => SQLVARCHAR ) [..] => Array ( ….. ) ) By using a for loop like […]

Trying to delete Database (MsSQL) from PHP with PDO

As the title might have explained, i have a php project here. Inside i use PDO to connect to my database. At first PHP was connected to a MySQL-Database. But now things have changed and I use a MsSQL-Database. In MySQL you can easily do the following: DROP DATABASE IF EXISTS mydatabase; How can this […]

Identify date format from a string in PHP

I am trying to update all of the date fields in the database to add 5 days to each date in all tables. I managed to pull the dates and row id into an array then generate a SQL code statement to update them. However, each table has a different date format some with time […]

Ampersand and number sign (& and #)

Ampersands and number signs do not get stored in MS SQL whenever I insert data (and it will cut the next word after the ampersand and number sign). I’m using an NVARCHAR column on my MS SQL Server 2014. For example if I type “AJ & J,” after I search it the output will be […]

Updating an existing user does not work in php

when I try to update my database to change the location of an existing user, I receive the text in an echo which is desired but the details of a user are not changed. Here is my code – server details have been removed on purpose for privacy. { $server = ”; $connectionInfo = array(“Database”=>””); […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.