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.php

Debugging Output

Row Before Delete

CustomerId: 1
Name: Miss Piggy
EmailAddress: queen@muppets.com
Gender: Female
EmailVerified: 1
DateLastModified: 2024-04-23 00:29:45
DateCreated: 2024-04-23 00:29:45
IsDirty:
Exists: 1
HasErrors:

Delete() - Number Of Rows Affected

1

Row After Delete

CustomerId:
Name: Miss Piggy
EmailAddress: queen@muppets.com
Gender: Female
EmailVerified: 1
DateLastModified: 2024-04-23 00:29:45
DateCreated: 2024-04-23 00:29:45
IsDirty:
Exists:
HasErrors: