本文整理汇总了PHP中Contest::loadFromDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP Contest::loadFromDatabase方法的具体用法?PHP Contest::loadFromDatabase怎么用?PHP Contest::loadFromDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contest
的用法示例。
在下文中一共展示了Contest::loadFromDatabase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadContest
static function loadContest($id)
{
return Contest::loadFromDatabase($id);
}
示例2: update
/**
* Aggiorna il post e le sue dipendenze nel database.
* Le dipendenze aggiornate sono quelle che dipendono dall'autore ovvero: tag e categorie
* Potrebbe salvare alcune tuple in Tag.
*
* @return: $this o FALSE se c'è un errore.
*/
function update()
{
$old = Contest::loadFromDatabase($this->getID());
$data = array();
if ($old->getTitle() != $this->getTitle()) {
$data[CONTEST_TITLE] = $this->getTitle();
}
if ($old->getDescription() != $this->getDescription()) {
$data[CONTEST_DESCRIPTION] = $this->getDescription();
}
if ($old->getEnd() != $this->getEnd()) {
$data[CONTEST_END] = $this->getEnd();
}
if ($old->getPrizes() != $this->getPrizes()) {
$data[CONTEST_PRIZES] = $this->getPrizes();
}
if ($old->getRules() != $this->getRules()) {
$data[CONTEST_RULES] = $this->getRules();
}
if ($old->getStart() != $this->getStart()) {
$data[CONTEST_START] = $this->getStart();
}
if ($old->getWinners() != $this->getWinners()) {
$data["ct_winners"] = $this->getWinners();
}
//TODO aggiornare i vincitori.
if ($old->getSubscriberType() == $this->getSubscriberType()) {
$data[CONTEST_TYPE_OF_SUBSCRIBER] = $this->getSubscriberType();
}
require_once "query.php";
$db = new DBManager();
if (!$db->connect_errno()) {
$table = Query::getDBSchema()->getTable(TABLE_CONTEST);
$rs = $db->execute($s = Query::generateUpdateStm($table, $data, array(new WhereConstraint($table->getColumn(CONTEST_ID), Operator::EQUAL, $this->getID()))), $table->getName(), $this);
//echo "<br />" . $s; //DEBUG
//echo "<br />" . mysql_affected_rows(); //DEBUG
if ($db->affected_rows() == 1) {
//echo "<br />" . $this; //DEBUG
return $this->getID();
} else {
$db->display_error("Contest::update()");
}
} else {
$db->display_connect_error("Contest::update()");
}
return false;
}