Answer the question
In order to leave comments, you need to log in
db_insert throws a PDOException when creating a row with implode(). Why?
In general, the fact is that when you try to add a row to the database, when forming it through implode (), a PDOException error pops up:
This does not work:
<?php
$test_array = array('Apple', 'Banan');
$test = implode($test_array, ", ");
db_insert('test')
->fields(array(
'nid' => 2,
'related' => $test,
'created' => time(),
))
->execute();
<?php
$test = 'Apple, Banan';
db_insert('test')
->fields(array(
'nid' => 2,
'related' => $test,
'created' => time(),
))
->execute();
Answer the question
In order to leave comments, you need to log in
In general, the problem was in the encoding, I did not understand why, but
I solved the problem
The arguments were mixed up in places, at least they looked at the logs, it’s probably written there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question