ok - Show me the code
ClientesMapper.php
[PHP]
<?php
class Application_Model_ClientesMapper {
protected $_dbTable;
public function setDbTable($dbTable) {
if (is_string($dbTable)) {
$dbTable = new $dbTable();
}
if (!$dbTable instanceof Zend_Db_Table_Abstract) {
throw new Exception('Invalid table date gateway provided');
}
$this->_dbTable = $dbTable;
return $this;
}
public function getDbTable() {
if (null === $this->_dbTable) {
$this->setDbTable('Application_Model_DbTable_Clientes' );
}
return $this->_dbTable;
}
public function save(Application_Model_clientes $clientes) {
$data = array(
'idclientes' => $clientes->getidclientes(),
'apellido' => $clientes->getapellido(),
'nombre' => $clientes->getnombre(),
'domicilio' => $clientes->getdomicilio());
if (null === ($id = $clientes->getidclientes())) {
unset($data['idclientes']);
$this->getDbTable()->insert($data);
} else {
$this->getdbTable()->update($data, array('idclientes = ?' => $id));
}
}
public function find($id, Application_Model_clientes $clientes) {
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
return;
}
$row = $result->current();
$clientes->setidclientes($row->idclientes)
->setapellido($row->apellido)
->setnombre($row->nombre)
->setdomicilio($row->domicilio);
}
public function fetchAll() {
$resultSet = $this->getDbTable()->fetchAll();
$entries = array();
foreach ($resultSet as $row) {
$entry = new Application_Model_Clientes();
$entry->setidclientes($row->idclientes)
->setapellido($row->apellido)
->setnombre($row->nombre)
->setdomicilio($row->domicilio);
$entries[] = $entry;
}
return $entries;
}
}
[PHP]
Clientes.php // esto esta dentro del forms
Código PHP:
<?php
class Application_Form_Clientes extends Zend_Form
{
public function init()
{
$this->setMethod('post');
$this->addElement('text', 'nombre', array (
'label' => 'Your is name:',
'requiered' => true,
'filters' => array ('stringTrim'),
));
$this->addElement('text', 'apellido', array (
'label' => 'Your is last:',
'requiered' => true,
));
$this->addElement('submit', 'submit', array (
'ignore' => true,
'label' => 'Sign Clientes',
));
}
}
Gracias por la ayuda