get NULL to be saved to file
I have a table that I am trying to save to an sql file using php. The
table has fields with NULL. However when I try and loop through the table
rows to save to file, the NULLs become blank strings, is there anything I
can do to prevent this? Below is a snippet of the code
$sql="SELECT * FROM myTable";
$sql_result=mysql_query($sql);
while ($row = mysql_fetch_array($sql_result,MYSQL_ASSOC)){
$saveSql.=$row['myId'].",";
$saveSql.="'".$row['myName']."',";
$saveSql.=$row['myAge'].",";
}
$handle = fopen('database.sql', 'w');
fwrite($handle,$saveSql);
If there are NULL values, then they are not saved to file, they are saved
as empty strings.
No comments:
Post a Comment