本文整理匯總了PHP中Vote::setCreationDate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Vote::setCreationDate方法的具體用法?PHP Vote::setCreationDate怎麽用?PHP Vote::setCreationDate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Vote
的用法示例。
在下文中一共展示了Vote::setCreationDate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: loadVotes
/**
* @deprecated il voto viene caricato attraverso getAvgVote()
* Carica in this i voti recuperati dal database per questo post (deve avere un ID!).
*/
function loadVotes()
{
require_once "query.php";
$db = new DBManager();
if (!$db->connect_errno()) {
define_tables();
defineVoteColumns();
$table = Query::getDBSchema()->getTable(TABLE_VOTE);
$rs = $db->execute($s = Query::generateSelectStm(array($table), array(), array(new WhereConstraint($table->getColumn(VOTE_POST), Operator::EQUAL, $this->getID())), array()), $table->getName(), $this);
//echo "<p>" . $s . "</p>"; //DEBUG;
if ($db->num_rows() > 0) {
$votes = array();
while ($row = $db->fetch_result()) {
require_once "post/PostCommon.php";
$vote = new Vote(intval($row[VOTE_AUTHOR]), intval($row[VOTE_POST]), $row[VOTE_VOTE] > 0);
$vote->setCreationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[VOTE_CREATION_DATE])));
$votes[] = $vote;
}
//echo "<p>" . serialize($votes) . "</p>"; //DEBUG;
$this->setVotes($votes);
} else {
if ($db->errno()) {
$db->display_error("Post::loadVotes()");
}
}
} else {
$db->display_connect_error("Post::loadVotes()");
}
return $this;
}
示例2: loadFromDatabase
/**
* Crea un voto caricando i dati dal database.
* È come fare una ricerca sul database e poi fare new Vote().
*
* @param $id: l'ID del voto da caricare.
* @return: il voto caricato o FALSE se non lo trova.
*/
static function loadFromDatabase($author, $post)
{
require_once "query.php";
$db = new DBManager();
if (!$db->connect_errno()) {
require_once 'strings/strings.php';
define_tables();
defineVoteColumns();
$table = Query::getDBSchema()->getTable(TABLE_VOTE);
$rs = $db->execute($s = Query::generateSelectStm(array($table), array(), array(new WhereConstraint($table->getColumn(VOTE_AUTHOR), Operator::EQUAL, $author), new WhereConstraint($table->getColumn(VOTE_POST), Operator::EQUAL, $post)), array()), $table->getName(), null);
if ($db->num_rows() == 1) {
$row = $db->fetch_result();
$v = new Vote(intval($row[VOTE_AUTHOR]), intval($row[VOTE_POST]), $row[VOTE_VOTE] > 0);
$v->setCreationDate(date_timestamp_get(date_create_from_format("Y-m-d G:i:s", $row[VOTE_CREATION_DATE])));
return $v;
}
//else $db->display_error("Vote::loadFromDatabase()");
} else {
$db->display_connect_error("Vote::LoadFromDatabase()");
}
return false;
}