Sample File: delete-by-email.php
The Code
<?php
//outline (see source for full code)
require_once("include/include.php");
//lookup the Customer row with the EmailAddress = "queen@muppets.com"
$Customer = $GLOBALS["db"]["Customer"]->LookupRow(array(
"EmailAddress" => "queen@muppets.com"
));
//note- instead of LookupRow() on the table, we can LookupRow() from the column:
//$Customer
// = $GLOBALS["db"]["Customer"]["EmailAddress"]->LookupRow("queen@muppets.com");
// -- BEFORE DELETE --
//print a message if the customer does not exist
if(!$Customer->Exists()){
echo "Customer with EmailAddress=queen@muppets.com not found to delete.";
}
//delete the row from the database. It`s fine if the row doesn`t exist.
$numRowsDeleted = $Customer->Delete();
// -- AFTER DELETE --
?>
https://github.com/cirkuitnet/PHP-SmartDB/blob/master/samples/basic/delete-by-email.phpDebugging Output
Row Before Delete
CustomerId: 3Name: Miss Piggy
EmailAddress: queen@muppets.com
Gender: Female
EmailVerified: 1
DateLastModified: 2024-11-21 08:44:57
DateCreated: 2024-11-21 08:44:57
IsDirty:
Exists: 1
HasErrors:
Delete() - Number Of Rows Affected
1Row After Delete
CustomerId:Name: Miss Piggy
EmailAddress: queen@muppets.com
Gender: Female
EmailVerified: 1
DateLastModified: 2024-11-21 08:44:57
DateCreated: 2024-11-21 08:44:57
IsDirty:
Exists:
HasErrors: