note 92669 added to function.mysql-field-flags

From: Date: Mon, 03 Aug 2009 14:07:12 +0000
Subject: note 92669 added to function.mysql-field-flags
Groups: php.notes 
Request: Send a blank email to php-notes+get-159029@lists.php.net to get a copy of this message
To really backup the database values, I made a little changement : My code really looks like bomas 's code, but there is an important diffence : $nbc = mysql_num_fields($req_table); while ($ligne = mysql_fetch_array($req_table)) { $insertions = "INSERT INTO $table VALUES("; for ($i=0; $i<$nbc; $i++) { if ( $i > 0 ) $insertions .= ", "; // /// The difference is here, the test on NULL value // if ( !isset($ligne[$i])) $insertions .= "NULL, "; else $insertions .= "'".mysql_real_escape_string($ligne[$i]) . "', "; } Before, I test that the values if not NULL into the field because it is the only way to make the difference, for example for string text fields, between NULL values and empty strings. If you don't make this test, you should find empty string instead of NULL values when you do the backup. ---- Server IP: 69.147.83.197 Probable Submitter: 193.48.245.123 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-field-flags.php Edit -- https://master.php.net/note/edit/92669 Del: integrated -- https://master.php.net/note/delete/92669/integrated Del: useless -- https://master.php.net/note/delete/92669/useless Del: bad code -- https://master.php.net/note/delete/92669/bad+code Del: spam -- https://master.php.net/note/delete/92669/spam Del: non-english -- https://master.php.net/note/delete/92669/non-english Del: in docs -- https://master.php.net/note/delete/92669/in+docs Del: other reasons-- https://master.php.net/note/delete/92669 Reject -- https://master.php.net/note/reject/92669 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#159029) next »