Answer the question
In order to leave comments, you need to log in
Why is PHP PDO converting text to binary?
I am using PHP PDO:
$statement = $connection->prepare("UPDATE item SET description = :desc WHERE id = :item_id");
$statement->execute([':desc' => 'Текст на русском и английском с элементами html большой длины (mediumText)', ':item_id' => 26]);
SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\x81<sup>...' for column 'description' at row 3
. In the request logs, I found that for some reason the data is already being transmitted in this form: {":item_id":26, ":desc":"(binary value)"}
, i.e. it is not clear why the description becomes a binary value, which is why an error occurs when executing the request, because in a db the field has data type MediumText, and cannot accept binary. How can this be fixed? Answer the question
In order to leave comments, you need to log in
SELECT cat1.id, cat1.cat_name, cat1.cat_url, cat1.parent, cat2.name as parent_name
FROM `categories` AS cat1
LEFT JOIN `categories` AS cat2 ON cat2.id = cat1.patent
WHERE cat1.`cat_url` = <значение>
You need something like:
SELECT * FROM `categories`
WHERE
IF (`cat_url` > 0, SELECT * FROM `table` )
GROUP BY...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question