本文整理汇总了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;
}