Updates records which meet given $condition.
This function returns true on success and null (=false) on failure. Please notice that it returns true also when no changes has been made to the $filename.
ptb_update('author.php', 'L', "'author' == 'Arthur Conan Doyle'", "'country' = '3'");
You can change values of more than one field at a time; new assignments should be separated with commas:
ptb_update('books.php', '', "'id' == {$_GET['id']}", "'stock' = {$_POST['changeStock']}, 'price' = {$_POST['changePrice']}");
You can't use functions as a replacement directly; this won't work:
ptb_update('books.php', '', "'id' == '5'", "'published' = date('Y')");
To insert function's result, you must use new variable:
$year = date('Y'); ptb_update('books.php', '', "'id' == '5'", "'published' = $year");
The variable value is treated as a string, i.e. you can't use this:
$year = date('Y'); ptb_update('books.php', '', "'id' == '5'", "'published' = ($year + 1)");
You can still use functions in $condition, though:
$year = date('Y'); ptb_update('books.php', '', "'id' == date('Y') + 1", "'published' = $year");