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: 1Name: Miss Piggy
EmailAddress: queen@muppets.com
Gender: Male
EmailVerified: 1
DateLastModified: 2024-12-19 18:14:49
DateCreated: 2024-12-19 18:14:49
IsDirty:
Exists: 1
HasErrors:
Delete() - Number Of Rows Affected
1Row After Delete
CustomerId:Name: Miss Piggy
EmailAddress: queen@muppets.com
Gender: Male
EmailVerified: 1
DateLastModified: 2024-12-19 18:14:49
DateCreated: 2024-12-19 18:14:49
IsDirty:
Exists:
HasErrors: