Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
Users extends Zend_Db_Table
{
const STATUS_OFF = 0;
const STATUS_ON = 1;
protected $select;
public function __construct ()
{
$this->select = $this->select();
}
public function getSelect ()
{
if (null === $this->select) {
throw new Zend_Exception('Select object is not set.');
}
return $this->select;
}
public funtion setSelect (Zend_Db_Table_Select $select)
{
$this->select = $select;
}
public funtion status ($status = self::STATUS_ON)
{
$this->select->where('status = ?', $status);
return $this->select;
}
public funtion hasAvatar ()
{
$this->select->where('avatar IS NOT NULL');
return $this->select;
}
}
$users = new Users();
$rows = $users->fetchAll($users->status()->hasAvatar());
* This source code was highlighted with Source Code Highlighter.public function status($status)
{
return $this->where('status = ?', $status);
}
public function sex($sex)
{
return $this->where('sex = ?', $sex);
}
* This source code was highlighted with Source Code Highlighter. public function call($method, $params)
{
return $this->where($method." = ".$params);
}
* This source code was highlighted with Source Code Highlighter. public function call($method, $params)
{
if(is_array($params) {
return $this->where($method." IN (".implode(',',$params).")");
} else {
return $this->where($method." = ".$params);
}
}
* This source code was highlighted with Source Code Highlighter.$topic = $this->getTopic(); // Topic or Null
if ($topic) {
return $this->render($topic);
} else {
return $this->http(404);
}function port ($argv) {
if (count($argv) != 1 || !$this->isPortCode($argv[0])) {
return $this->http(404);
}
$port = $this->getPort($argv[0]);
if (!$port) {
return $this->http(404);
}
return $this->renderPort($port);
}
function portsList ($argv) {
if ($argv) {
return $this->http(404);
}
return $this->renderPortsList();
}
Named scope для Zend Framework