Posted by JM on 01/21/07 18:55
When you pass an array to a function that will update a record in a
database.
for example:
function doIt($file) {
//connect to database
$sql = 'UPDATE Files ' .
"SET FileName = '" . $file['FileName']. "', " .
// what if $file['Author'] or $file['Description']
// equals null or ''? Should I test for this and construct
// my sql statement as a result of several if statements ?
// or is there another possibility ?
// FileID and FileName cannot be null so this is easy,
// but what for the other fields
"WHERE FileID = '" . $file['FileID'] . "'"
// execute sql
// return result
}
JM
Navigation:
[Reply to this message]
|