Build insert query from array MySQL and PHP
问题 I'm writing a small web service in PHP and I'm having a bit of trouble getting my head around the following scenario. My plan is to be able to send an array of data to a function, which would then build a query for MySQL to run. In the array I plan for the key to be the column name, and the value to be the value going in to the columns.. i.e. $myData = array('userName'=>'foo','passWord'=>'bar'); $myClass = new users(); $myClass->addUser($myData); Then, in my function I currently have: