Sample File: insert.php

The Code

<?php

//outline (see source for full code)
require_once("include/include.php");

//create a new Customer row
$Customer = $GLOBALS["db"]["Customer"]->GetNewRow();

//note- as a shortcut to GetNewRow(), we could simply do:
//$Customer = $GLOBALS["db"]["Customer"]();

// -- NEW ROW -- 

//set the customer row cells with data
$Customer["Name"] = "Jack Frost";
$Customer["EmailAddress"] = "jfrost@winter.com";
$Customer["Gender"] = "Male";
$Customer["DateCreated"] = gmdate("Y-m-d H:i:s T");
$Customer["DateLastModified"] = gmdate("Y-m-d H:i:s T");

// -- AFTER SET FIELDS, BEFORE COMMIT -- 

//check for errors before we commit
//HasErrors() returns nothing when there are no errors
if( ($errors=$Customer->HasErrors()) ){
	echo "Errors found: ".$errors;	
}
else{
	//commit this row to the database
	$numRowsInserted = $Customer->Commit();
}

// -- AFTER COMMIT --
?>
https://github.com/cirkuitnet/PHP-SmartDB/blob/master/samples/basic/insert.php

Debugging Output

New Row

CustomerId:
Name:
EmailAddress:
Gender:
EmailVerified: 0
DateLastModified:
DateCreated:
IsDirty:
Exists:
HasErrors: 'Name' field is required.
'Email Address' field is required.
'Gender' field is required.

Row After Set Fields, Before Commit

CustomerId:
Name: Jack Frost
EmailAddress: jfrost@winter.com
Gender: Male
EmailVerified: 0
DateLastModified:
DateCreated:
IsDirty: 1
Exists:
HasErrors: Selected 'Email Address' (jfrost@winter.com) is already in use. Please select another value.

Errors Found

Selected 'Email Address' (jfrost@winter.com) is already in use. Please select another value.

Commit() - Number Of Rows Affected

0

Row After Commit

CustomerId:
Name: Jack Frost
EmailAddress: jfrost@winter.com
Gender: Male
EmailVerified: 0
DateLastModified:
DateCreated:
IsDirty: 1
Exists:
HasErrors: Selected 'Email Address' (jfrost@winter.com) is already in use. Please select another value.