Esto tengo dentro del model / clientes.php
Código PHP:
<?php
class Application_Model_Clientes {
protected $_idclientes;
protected $_nombre;
protected $_apellido;
protected $_domicilio;
public function __construct(array $options = null) {
if (is_array($options)) {
$this->setOptions($options);
}
}
public function __set($name, $value) {
if (('mapper' == $name) || !method_exists($this, $method)) {
throw new Exception('Invalid Clientes property');
}
$this->$method($value);
}
public function __get($name)
{
$method = 'get' . $name;
if(('mapper' == $name) || !method_exists($this, $method)){
throw new Exception('Invalid Cliente Property');
}
return $this->$method();
}
public function setOptions(array $options)
{
$methods = get_class_methods($this);
foreach ($options as $key => $value){
$method = 'set' . ucfirst($key);
if (in_array ($method, $methods)){
$this-> $method($value);
}
}
return $this;
}
public function setidclientes ($text)
{
$this->_idclientes = (string)$text;
return $this;
}
public function getidclientes ()
{
return $this->_idclientes;
}
public function setnombre($nombre)
{
$this->_nombre = (string) $nombre;
return $this;
}
public function getnombre ()
{
return $this->_nombre;
}
public function setapellido ($apellido)
{
$this->_apellido = (string)$apellido;
return $this;
}
public function getapellido ()
{
return $this->_apellido;
}
public function setdomicilio ($domicilio)
{
$this->_domicilio = (string)$domicilio;
return $this;
}
public function getdomicilio ()
{
return $this->_domicilio;
}
}
y esto dentro del controlller/ clientesController.php
Código PHP:
<?php
class ClientesController extends Zend_Controller_Action {
public function init() {
/* Initialize action controller here */
}
public function indexAction() {
$clientes = new Application_Model_ClientesMapper();
$this->view->entries = $clientes->fetchAll();
}
public function signAction() {
$request = $this->getRequest();
$form = new Application_Form_Clientes();
if ($this->getRequest()->isPost()) {
if ($form->isValid($request->getPost())) {
$ape = new Application_Model_Clientes($form->getValues());
$mapper = new Application_Model_ClientesMapper();
$mapper->save($ape);
return $this->_helper->redirector('index');
}
}
$this->view->form = $form;
}
}