本文整理汇总了PHP中Entry::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP Entry::setName方法的具体用法?PHP Entry::setName怎么用?PHP Entry::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entry
的用法示例。
在下文中一共展示了Entry::setName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Entry
<?php
// submit_entry.php
require_once "bootstrap.php";
$email = $_POST['email'];
$name = $_POST['name'];
//var_dump($_POST);
try {
$entry = new Entry();
$entry->setEmail($email);
$entry->setName($name);
$entry->setIpAddr($_SERVER['REMOTE_ADDR']);
$em->persist($entry);
$em->flush();
} catch (Exception $e) {
die('{"status": 401, message: "Sorry, you have already entered once this round."}');
}
$query = $em->createQuery('SELECT COUNT(e.id) FROM Entry e');
$count = $query->getSingleScalarResult();
if ($count >= 3) {
$prizes = $em->getRepository('Prize')->findBy(array('awarded' => false));
$prize = $prizes[array_rand($prizes)];
$prize->setAwarded(true);
$offset = max(0, rand(0, 2));
$query = $em->createQuery('SELECT DISTINCT e FROM Entry e')->setMaxResults(1)->setFirstResult($offset);
$winningEntry = $query->getScalarResult()[0];
$winner = new Winner();
$winner->setEmail($winningEntry['e_email']);
$winner->setName($winningEntry['e_name']);
$winner->setIpAddr($winningEntry['e_ip_addr']);
$winner->setPrize($prize);
示例2: cloneEntry
public function cloneEntry($sourceEntry, $targetEntry)
{
$criteria = $this->getCriteria()->select("idEntry, name, description, nick, idLanguage");
$criteria->where("entry = '{$sourceEntry}'");
$criteria->asQuery()->each(function ($row) use($targetEntry) {
$entry = new Entry();
$entry->setEntry($targetEntry);
$entry->setName($row['name']);
$entry->setDescription($row['description']);
$entry->setNick($row['nick']);
$entry->setIdLanguage($row['idLanguage']);
$entry->save();
});
}