本文整理汇总了PHP中Dao::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Dao::load方法的具体用法?PHP Dao::load怎么用?PHP Dao::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dao
的用法示例。
在下文中一共展示了Dao::load方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCount
function getCount($object)
{
parent::load($object);
$objectClass = get_class($object);
$rs = $this->db->execute($s = Query::generateSelectStm(array($this->table), array(), array(new WhereConstraint($this->table->getColumn(REPORT_OBJECT_ID), Operator::EQUAL, $object->getID()), new WhereConstraint($this->table->getColumn(REPORT_OBJECT_CLASS), Operator::EQUAL, get_class($object))), array("count" => 2)));
if ($this->db->num_rows() != 1) {
throw new Exception("Si è verificato un errore. Riprovare.");
}
$row = $this->db->fetch_row();
return intval($row[0]);
}
示例2: loadByNickname
function loadByNickname($nickname)
{
parent::load($nickname);
$this->db->execute($s = Query::generateSelectStm(array($this->table), array(), array(new WhereConstraint($this->table->getColumn(DB::USER_NICKNAME), Operator::EQUAL, $nickname)), array()));
if ($this->db->num_rows() != 1) {
throw new Exception("L'oggetto cercato non è stato trovato. Riprovare.");
}
$row = $this->db->fetch_result();
$user = $this->createFromDBRow($row);
return $user;
}
示例3: loadParentName
function loadParentName($cat)
{
parent::load($cat);
if (!is_a($cat, "Category")) {
throw new Exception("Attenzione! Il parametro di ricerca non è una categoria.");
}
$this->db->execute($s = Query::generateSelectStm(array($this->table_sc), array(), array(new WhereConstraint($this->table_sc->getColumn(DB::SUB_CATEGORY_CATEGORY), Operator::EQUAL, $cat->getName())), array()));
if ($this->db->num_rows() == 1) {
$row = $this->db->fetch_result();
$cat->parent = $row[DB::SUB_CATEGORY_PARENT];
}
return $cat;
}
示例4: loadForAuthor
function loadForAuthor($author)
{
parent::load($author);
if (!is_subclass_of($post, "User")) {
throw new Exception("Attenzione! Il parametro di ricerca non è un utente.");
}
$this->db->execute(Query::generateSelectStm(array($this->table), array(), array(new WhereConstraint($this->table->getColumn(DB::RESOURCE_OWNER), Operator::EQUAL, intval($author->getID()))), array()));
$resources = array();
while ($row = $db->fetch_result()) {
$resources[] = $this->createFromDBRow($row);
}
return $resources;
}
示例5: __construct
public function __construct(array $params = array())
{
if (!empty($params)) {
$vars = get_object_vars($this);
foreach ($params as $k => $v) {
if (array_key_exists($k, $vars)) {
$this->{$k} = $v;
}
}
}
if (isset($this->adresse)) {
$this->adresse = Dao::load($this->adresse, 'adresse');
$this->linkObject = array('adresse');
}
}
示例6: exists
function exists($vote)
{
parent::load($vote);
$post = $vote["post"];
$author = $vote["author"];
parent::load($post);
if (!is_subclass_of($post, "Post")) {
throw new Exception("Attenzione! Il parametro di ricerca non è un post.");
}
parent::load($author);
if (!is_a($post, "User")) {
throw new Exception("Attenzione! Il parametro di ricerca non è un utente.");
}
$this->db->execute(Query::generateSelectStm(array($this->table), array(), array(new WhereConstraint($this->table->getColumn(DB::VOTE_POST), Operator::EQUAL, intval($post->getID())), new WhereConstraint($this->table->getColumn(DB::VOTE_AUTHOR), Operator::EQUAL, intval($author->getID()))), array()));
return $this->db->num_rows() > 0;
}
示例7: loadAll
function loadAll($post)
{
parent::load($post);
if (!is_subclass_of($post, "Post")) {
throw new Exception("Attenzione! Il parametro di ricerca non è un post.");
}
$rs = $this->db->execute($s = Query::generateSelectStm(array($this->table), array(), array(new WhereConstraint($this->table->getColumn(DB::COMMENT_POST), Operator::EQUAL, intval($post->getID()))), array()), $this->table->getName(), $this);
$comm = array();
if ($this->db->num_rows() > 0) {
while ($row = $this->db->fetch_result()) {
$c = new Comment($row[DB::COMMENT_COMMENT], intval($row[DB::COMMENT_POST]), intval($row[DB::COMMENT_AUTHOR]));
$com->setID($row[DB::COMMENT_ID])->setCreationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[DB::COMMENT_CREATION_DATE])));
$comm[] = $com;
}
}
return $post->setComments($comm);
}
示例8: loadAll
function loadAll($user)
{
parent::load($user);
if (is_numeric($user)) {
$id = $user;
} else {
if (!is_a($user, "User")) {
throw new Exception("Attenzione! Il parametro di ricerca non è un utente.");
}
$id = $user->getID();
}
$this->db->execute(Query::generateSelectStm(array($this->table, $this->table_ct), array(new JoinConstraint($this->table->getColumn(DB::CONTACT_NAME), $this->table_ct->getColumn(DB::CONTACT_TYPE_NAME))), array(new WhereConstraint($this->table->getColumn(DB::CONTACT_USER), Operator::EQUAL, intval($id))), array()));
$conts = array();
while ($row = $this->db->fetch_result()) {
$conts[] = $this->createFromDBRow($row);
}
return $conts;
}
示例9: load
function load($rl_name)
{
parent::load($rl_name);
$result = array();
$query = "SELECT * FROM " . DB::TABLE_ROLE . " WHERE " . DB::ROLE_NAME . " = '" . $rl_name . "'";
// query usando le const
$this->db->execute($query);
//eseguo la query con l'oggetto DBManager che hanno tutti i DAO
if ($this->db->num_rows() != 1) {
//controllo la quantit� di risultati
throw new Exception("L'oggetto cercato non � stato trovato. Riprovare.");
}
$res = $this->db->fetch_result();
//recupero il primo (e unico) risultato.
//TRUCCO!!! il risultato � gi� in un array associativo dove l'indice � il nome della colonna...
//posso ritornarlo direttamente cos�...
//ma se voglio fare qualche cosa in pi�, posso fare cos�:
foreach ($res as $index => $value) {
$result[$index] = $value > 0;
}
//metto nell'array dei valori booleani
return $result;
}
示例10: permalinkExists
function permalinkExists($permalink)
{
parent::load($permalink);
$rs = $this->db->execute($s = Query::generateSelectStm(array($this->table), array(), array(new WhereConstraint($this->table->getColumn(DB::POST_PERMALINK), Operator::EQUAL, $permalink)), array("count" => 2)));
if ($this->db->num_rows() != 1) {
throw new Exception("Si è verificato un errore. Riprovare.");
}
$row = $this->db->fetch_row();
return $row[0] > 0;
}
示例11: loadWinners
private function loadWinners()
{
parent::load($contest);
if (!is_subclass_of($contest, self::OBJECT_CLASS)) {
throw new Exception("Attenzione! Il parametro di ricerca non è un contest.");
}
$s = "SELECT * FROM " . $this->table_cs->getName() . " WHERE " . DB::CONTEST_SUBSCRIBER_PLACEMENT . " IS NOT NULL ORDER BY " . DB::CONTEST_SUBSCRIBER_PLACEMENT . " ASC";
$rs = $this->db->execute($s, $this->table_cs->getName(), $contest);
$subscribers = array();
while ($row = $this->db->fetch_result()) {
require_once 'dao/PostDao.php';
$postdao = new PostDao();
$subscribers[] = $postdao->quickLoad(intval($row[CONTEST_SUBSCRIBER_POST]));
}
return $contest->setSubscribers($subscribers);
}