Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Php PDO Insert statement

Someone told me that when you are working with PDO, you cannot use "INSERT INTO .... SET" to insert data into database, because it will not work on databases other than MySQL. I'm not sure what exactly he means, maybe he means I should use the other method of inserting like,

INSERT INTO table (column1, column2) VALUES (?, ?)

I tried searching on the internet for this, but I couldn't find anything. Please let me know about this.

Thank you.

like image 713
Sameer Zahid Avatar asked Jun 25 '26 17:06

Sameer Zahid


1 Answers

You should use the INSERT INTO table (column1, column2) VALUES (?, ?) statement instead of the INSERT INTO table SET column1=? statement, because that's the correct syntax for SQL based database languages. Although MySQL accepts it, others may not.

like image 73
vonUbisch Avatar answered Jun 27 '26 07:06

vonUbisch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!