Mhtml
02-21-2007, 10:58 PM
Hiya, just threw together a generic active record class and I've sort of got a bit of coder's block... Just can't see my next step :rolleyes:...
Basically my problem is binding it to a row, how should I handle it?
public function commit(){
if($this->prv_rowBound){
$this->prv_dbInst->query(sql::update($this->prv_table, $this->prv_vars, [...]));
}else{
$this->prv_dbInst->query(sql::insert($this->prv_table, $this->prv_vars));
}
}
The sql helper, update, has to take a primary key.
If the object is created from a row request, then it needs to be bound to a primary key so changes can be commited... But right now the neatest way to do this eludes me. Right now the sql::update helper expects `id` as a primary key. But this isn't exactly flexible.
Thoughts?
Basically my problem is binding it to a row, how should I handle it?
public function commit(){
if($this->prv_rowBound){
$this->prv_dbInst->query(sql::update($this->prv_table, $this->prv_vars, [...]));
}else{
$this->prv_dbInst->query(sql::insert($this->prv_table, $this->prv_vars));
}
}
The sql helper, update, has to take a primary key.
If the object is created from a row request, then it needs to be bound to a primary key so changes can be commited... But right now the neatest way to do this eludes me. Right now the sql::update helper expects `id` as a primary key. But this isn't exactly flexible.
Thoughts?