Skip to content

Instantly share code, notes, and snippets.

@phpdave
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpdave/b069eecd98c36dbb1155 to your computer and use it in GitHub Desktop.
Save phpdave/b069eecd98c36dbb1155 to your computer and use it in GitHub Desktop.
ZF1 Model column with a #
<?php
class Model
{
protected $_dbh = null;
protected $_table = 'MYTABLE';
public function __construct()
{
$registry = Zend_Registry::getInstance();
$this->_dbh = $registry->dbAdapter;
}
//CREATE
public function insert($data)
{
$this->_dbh->insert($this->_table, $data);
}
//READ
public function fetchRowByCol($bind)
{
return $this->_dbh->fetchRow("SELECT * FROM ".$this->_table." WHERE MYCOL# = ? ",$bind);
}
//UPDATE
public function update($data, $value)
{
$where['MYCOL# = ?'] = $value;
return $this->_dbh->update($this->_table, $data, $where);
}
//DELETE
public function delete($value)
{
$where['MYCOL# = ?'] = $value;
return $this->_dbh->update($this->_table, $where);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment