33 lines
863 B
PHP
33 lines
863 B
PHP
|
<?php
|
||
|
abstract class Libs_Row extends Zend_Db_Table_Row_Abstract
|
||
|
{
|
||
|
public function __construct(array $input = array())
|
||
|
{
|
||
|
$class = explode('_', get_class($this));
|
||
|
$this->_tableClass = 'Table_' . array_pop($class) . 's'; // le 's' final
|
||
|
parent::__construct($input);
|
||
|
$cols = $this->_table->info(Zend_Db_Table_Abstract::COLS);
|
||
|
if (!isset($input['data'])) {
|
||
|
$input['data'] = array_combine($cols, array_pad(array(),count($cols),null));
|
||
|
}
|
||
|
$this->_data = $input['data'];
|
||
|
}
|
||
|
|
||
|
public function getForm($form = null)
|
||
|
{
|
||
|
$formObject = $this->getTable()->getForm($form);
|
||
|
if ($this->_data[$this->_primary[1]] != null && $form == null) {
|
||
|
$formObject->populate($this->_data);
|
||
|
}
|
||
|
return $formObject;
|
||
|
}
|
||
|
|
||
|
public function save()
|
||
|
{
|
||
|
$form = $this->getForm();
|
||
|
if (!$form->isValid($this->_data)) {
|
||
|
return false;
|
||
|
}
|
||
|
return parent::save();
|
||
|
}
|
||
|
}
|