Skip to main content

All Questions

Tagged with
1 vote
4 answers
112 views

PDO Inside a Function

I just recently began converting my database queries to PDO. I define $dsn, $opt and $pdo on a separate file that's included in every page on my website. I then have a simple row-count query in ...
0 votes
1 answer
35 views

How to unbind some columns from PDO prepare statement [duplicate]

Let's say I have a regular prepare statement, but sometimes I must omit some columns from being updated: $stmt = $db->prepare("UPDATE table SET price = ?, size = ?, color = ? ...
77 votes
13 answers
182k views

PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers

I'm trying to connect to a MySQL database from Symfony 3 application. But when trying to create MySQL schema from a Symfony console command I get this error: PDO::__construct(): Server sent charset (...
1 vote
1 answer
1k views

[Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Login failed for user

I'm integrating MSSQL Server into my PHP 8.0 application using a Docker container. I've installed the pdo_sqlsrv,sqlsrv and unixodbc extensions, and for that, I've also installed ODBC Driver 18 for ...
1 vote
0 answers
64 views

Cloud SQL issue after PHP update to 8.2

I am using PDO connection for Cloud SQL from website. I have updated PHP to 8.2 recently and connection has stopped working and giving error [MY-010914] [Server] Bad handshake even though there is ...
0 votes
1 answer
129 views

Looking for PDO Informix extension for PHP 8.3 [closed]

I'm trying to connect my Php 8.3 (x64) to IBM Informix database. I have found pre-compiled versions of the extension for PHP 8.0 and 8.1 but it doesn't work with PHP 8.3. Does anyone have this ...
0 votes
1 answer
190 views

Find mismatch between variables and bound tokens in Yii

I am using prepared statement to insert data. I am getting the 'Invalid parameter number: number of bound variables does not match number of tokens.' I have tried dumping the prepared statement but I ...
0 votes
0 answers
32 views

php Getting the COUNT [duplicate]

I’m looping through a user table to check if they exist in another table. It sounds simple enough, but I’m not able to the results I need. Running this query tells me if the user exists: SELECT COUNT(*...
3 votes
2 answers
1k views

Error in my PDO fetch column function: "Call to a member function fetchColumn() on a non-object" [closed]

I am using PDO object for executing query in PHP: $stmt = $this->db->prepare('select email from users where email = :email'); return (bool) $stmt->execute(array(':email' => $email))->...
9 votes
10 answers
45k views

mysql server has gone away error during installing migration (laravel)

So I am using my cmd on my laravel folder and I tried to do (php artisan migrate:install). 2 errors came up. [PDOException] SQLSTATE[HY000] [2006] MySQL server has gone away [ErrorException] PDO:...
0 votes
3 answers
1k views

Best way to remove the trace information from the PDOException __toString method [duplicate]

Is it possible to remove the trace elements from the __toString. What I want is something like this. class DBException extends PDOException { public function __toString() { return get_class($...
52 votes
3 answers
37k views

PDO fetchAll array to one dimensional

this may be a simple question but am struggling to understand how to solve it. I have a form which allows the user to select either "custom" or "all" staff" to assign to a job. If custom is selected ...
6 votes
4 answers
1k views

Why is PDO converting my bool(false) param to string('')?

I have a problem with a new MariaDB 10.5.8 install. STRICT_TRANS_TABLES is set, and when I try to use $sql of: 'INSERT INTO test (flag) VALUES (?)' (where flag is defined as tinyint(1)) with ...
2 votes
2 answers
1k views

PDO-MySQL: Boolean values get converted to 1 or empty string on prepared statement binding

I'm trying to insert some boolean values into JSON-type columns. $taskSql = "INSERT INTO Tasks (data, taskListId) VALUES (JSON_OBJECT('title', :title, 'done', :done), :taskListId)"; $taskStatement = $...
-1 votes
1 answer
37 views

Return row ID # to be used in next execute() statement? [duplicate]

I have three tables, one master table for plant readings, whose id is the foreign key that associates multiple readings from the compressor table and the ice temperatures table. I want to get the id ...

15 30 50 per page
1
3 4
5
6 7
1479