PersistClass is a library of PHP classes providing access to relational databases. Attempts to focus on simplicity and convenience by eliminating the need of boiler-plate, unmeaningful code.
Acquire a connection object
$con = DbConnectionPool::instance()->getConnection();
Execute an SQL query
$sql = 'INSERT INTO TESTTABLE(testcolumn) VALUES("INSERTSUCCESS")';
$con->query($sql);
Perform an SQL select, reading results
$sql = 'SELECT testcolumn FROM TESTTABLE';
$con->query($sql);
while($row = $con->next()) {
$testColumn = $row['testcolumn'];
}
Mapping a PHP class to a Database table
class TestTable extends PersistClass {
protected $sqlTableName = 'TESTTABLE';
protected $sqlPrimaryKey = 'testid';
}
Read SQL data using mapped objects
$testRecord = new TestTable(5); // 5 is a primary key
$testColumn = $testRecord->getData('testcolumn');
$otherTestColumn = $testRecord->getData('testcolumn');
Manipulate table data through mapped objects
$testRecord->setData('testcolumn', 'new content');
$testRecord->setData('othertestcolumn', 'other new content')
$testRecord->updateDb();
Check out the examples page with detailed explanations of common use cases