PDO: INSERT array into table


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
5 views
For mysql to insert many rows need to run something like
INSERT INTO ids VALUES
(0, 'http://url1.ru'),
(0, 'http://url2.ru'),
(0, 'http://url3.ru');

so here's the problem: have an array and need to insert into the plate. He is one-dimensional and assume that the column in the table too. Is there any PDO function to implement it. Google did not answer..(
by | 5 views

1 Answer

0 like 0 dislike
I do so:
\r
\r
$stmt = $db->prepare('INSERT INTO ids VALUES (0, :url)'); try { $db->beginTransaction(); foreach ($ursl as $url) { $stmt->bindValue(':url', $url); $stmt->execute(); } $db->commit(); } catch (PDOException $e) { $db->rollBack(); } 
by

Related questions

0 like 0 dislike
3 answers
asked May 20, 2019 by WebmasterW3S
0 like 0 dislike
1 answer
asked Apr 9, 2019 by dudoser
110,608 questions
257,186 answers
0 comments
27,859 users