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:
Name:
EmailAddress: queen@muppets.com
Gender:
EmailVerified: 0
DateLastModified:
DateCreated:
IsDirty: 1
Exists:
HasErrors: 'Name' field is required.
'Gender' field is required.

Errors Found

Customer with EmailAddress=queen@muppets.com not found to delete.

Delete() - Number Of Rows Affected

0

Row After Delete

CustomerId:
Name:
EmailAddress: queen@muppets.com
Gender:
EmailVerified: 0
DateLastModified:
DateCreated:
IsDirty: 1
Exists:
HasErrors: 'Name' field is required.
'Gender' field is required.