/** * Creates a new record * * @param array $columns A column-value mapped array * @param \Opis\Database\Connection $connection (optional) Database connection * * @return \Opis\Database\Model */ public static function create(array $columns, Connection $connection = null) { if ($connection === null) { $connection = static::getConnection(); } $item = new static(false, $connection); $item->assign($columns); $item->save(); return $item; }
/** * Make an entity statically. * * @param array $stack Array of your entities * * @return mixed */ public static function make(array $stack) { $instance = new static(); return $instance->assign($stack); }
/** Clone current object and returns it. If a _clone method * exists on the object, it will be used to create the new * object. This _clone member function is mandatory if the * ctor takes arguments. * \return object\base The new object cloned from $this */ public final function __clone() { if (method_exists($this, '_clone')) { $new = $this->_clone(); } else { $new = new static(); $new->assign($this); } return $new; }
public static function page($template, $data = array()) { $tpl = new static(); $tpl->assign('data', $data); echo $tpl->render($template); }