PHP PDO dblib parameters not bound -


I have to connect to an external SQL database. I am using PDO dblib

The connection works fine. Once I try to use the prepared statement, the parameters are not set.

  $ dbh = new PDF (sprintfo ('dblib: host =% s; dbname =% s', self: DB_HOST, auto :: DB_NAME), auto :: DB_USERNAME, auto :: DB_PASSWORD); $ Dbh- & gt; Prepare ("Select from * Contact Where to Ref = = Id"); $ Sth- & gt; Execute (array (': id' => 1172)); $ Result = $ sth- & gt; Get All (PDO :: FETCH_CLASS);  

returns an empty array

Another attempt, according to the document: ()

  $ dbh- & gt; Ready ("select * contacts WHERE ref =?"); $ Sth- & gt; Amal (Array (1172)); $ Result = $ sth- & gt; Get All (PDO :: FETCH_CLASS);  

also returns an empty table

The third attempt without parameters:

  $ dbh- & gt; Ready ("Select" WHERE Ref = 1172 "); $ Sth- & gt; Executed (); $ Result = $ sth- & gt; Get All (PDO :: FETCH_CLASS);  

returns a result

I also tried $ sth-> bindParam () and $ sth-> bindValue () but I did not get any results.

I have installed dblib on a Linux server, which is connected to an external Microsoft 2008 SQL Server.

Am I doing it wrongfully?

From the documentation of:

input_parameters

< Blockquote>

There are many elements in the form of an array of values ​​as there are bound parameters in the SQL statement being executed. All values ​​are considered as PDO :: PARAM_STR .

The last sentence may be a source of your problem: Your database may not be the same as 1172 '1172' . The result of the following query is 0 :

  select 1172 = '1172'; Check with CLI;  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -