Sample File: custom-truncate-sql.php
The Code
<?php
//outline (see source for full code)
require_once("include/include.php");
//using "count" on a table will return the total number of rows in that table
$totalNumRows = count($GLOBALS["db"]["Customer"]);
// -- BEFORE TRUNCATE --
//Execute our custom SQL. You will almost never want to write custom SQL, as this
//will completely bypass table/syntax checking, not use software row caching, and
//restrict your software to 1 particular back-end database that supports your SQL
//syntax. You CAN use Select(), Update(), Insert(), and Delete() within the
//DbManager to create completely custom queries. THOUGH, the SmartDatabase should
//be able to take care of 99%+ of your data-access though. DbManager queries are
//only recommended for the advanced.
$customerTablename = $GLOBALS["db"]["Customer"]->TableName; //i.e. "Customer"
$GLOBALS["dbManager"]->Query("TRUNCATE TABLE `$customerTablename`");
//Note- to remove all rows of a table, we should do this instead:
//$GLOBALS["db"]["Customer"]->DeleteAllRows();
//using "count" on a table will return the total number of rows in that table
$totalNumRows = count($GLOBALS["db"]["Customer"]);
// -- AFTER TRUNCATE --
?>
https://github.com/cirkuitnet/PHP-SmartDB/blob/master/samples/basic/custom-truncate-sql.phpDebugging Output
Before Truncate - Total 'Customer' Rows
1After Truncate - Total 'Customer' Rows
0