ActiveRecord methods:
add($row) // an associative array attribute=value
remove($row) // an associative array attribute=value, only primary key is required
update($row) // an associative array attribute=value, primary key is used for WHERE, other attributes for SET
get($where, $parameters) // a prepared statement and it's parameters
count($where, $parameters) // a prepared statement and it's paramters
And then some functions that have influence on the backend sql, but apart from the orderby and limit they shouldn't be used. (setters and getters for select, from, where, groupby, having, orderby, limit clauses).
----------------------------------------------------------------------------------
Now, if you have a Customer and Customers class, you could easily use composition to achieve some storage:
Code: Select all
class Customer
{
// customer attributes
var $firstname;
var $lastname;
function getAttributes()
{
return array('firstname', 'lastname');
}
function setFirstName($firstname)
{
$this->firstname = $firstname;
}
function getFirstName()
{
return $this->firstname;
}
}
class Customers
{
// backend
var $activerecord;
function addCustomer($customer)
{
$row = array();
$attributes = $customer->getAttributes();
foreach($attributes as $attribute)
{
$row[$attribute] = $customer->get{$attribute}();
}
$activerecord->add($row);
}
}