I created a script to dump my database, the script is working good but there is something I dont like about it.
The ( ' ), How do I dump my tables without having to remove this in every column that it gets fetched?
This part of my script looks like:
$query = $db->query("SELECT * FROM {$table}");
$numrows = mysqli_num_rows($query);
if($numrows != 0) {
$insert .= "INSERT INTO {$table} ($fields) VALUES \n";
while($row = $query->fetch_array())
{
$insert .= "(";
$comma = '';
foreach($field_list as $field)
{
$row[$field] = preg_replace("#\'#", "", $row[$field]);
$insert .= $comma."'".$db->real_escape_string($row[$field])."'";
$comma = ', ';
}
$insert .= "),\n";
}
$insert = substr($insert, 0, -2);
$insert .= ";\n";
I get rid of the string using this code
$row[$field] = preg_replace("#\'#", "", $row[$field]);
and it works, but is there a way to dump the table without having to remove that and the dump to still be able to be imported ?
Thanks.
Aucun commentaire:
Enregistrer un commentaire