quindi mi conviene procedere nel classico modo, farmi tutte le query e non una cosa del genere:

Codice PHP:

function _arrayToSql($table$array$insert "INSERT INTO") {

  
//Check if user wants to insert or update
  
if ($insert != "UPDATE") {
    
$insert "INSERT INTO";
  }

  
$columns = array();
  
$data = array();
  
  foreach ( 
$array as $key => $value) {
    
$columns[] = $key;
    if (
$value != "") {
      
$data[] = "'" $value "'";
    } else {
      
$data[] = "NULL";
    }
                
    
//TODO: ensure no commas are in the values
  
}
            
  
$cols implode(",",$columns);
  
$values implode(",",$data);

$sql = <<<EOSQL
  $insert `$table`
  (
$cols)
  VALUES
  (
$values)
EOSQL;
      return 
$sql;

}
//End _arrayToSql()