PHP Generated SQL
Wednesday, May 21st, 2008If you find yourself laboriously building SQL queries by typing each field = 'value' statement... think again.
Imagine this:
-
-
$insert_elsewhere_sql = "INSERT INTO other_table SET ";
-
-
foreach($s as $k=>$v){
-
$insert_elsewhere_sql .= "$k = '$v', ";
-
}
-
This will generate a valid SQL insert statement with all of your field, value pairs set up.
Time saver or what?
