本文整理汇总了PHP中DatabaseFactory::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseFactory::getInstance方法的具体用法?PHP DatabaseFactory::getInstance怎么用?PHP DatabaseFactory::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseFactory
的用法示例。
在下文中一共展示了DatabaseFactory::getInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInitialEventsList
public function getInitialEventsList()
{
$sql = 'SELECT e.*, o.id AS organizerId, o.title AS organizerTitle FROM events e LEFT JOIN organizers o ON e.organizer = o.id WHERE e.dateStart > now()';
$stmt = DatabaseFactory::getInstance()->prepare($sql);
$stmt->execute();
return $stmt->fetchAll();
}
示例2: sendEmail
function sendEmail($recipient, $content, $subject = 'Notification', $includeStandardFooter = true)
{
$subject = 'lanlist.org - ' . $subject;
if (empty($content)) {
throw new Exception('Cannot send a blank email');
}
$content = wordwrap($content);
if ($includeStandardFooter) {
$content .= "\n\n- lanlist.org";
}
ErrorHandler::getInstance()->beLazy();
require_once 'Mail.php';
require_once 'Mail/smtp.php';
$host = 'ssl://smtp.gmail.com';
$username = 'xconspirisist@lanlist.org';
$password = 'ionicflame312';
$smtp = new Mail_smtp(array('host' => $host, 'port' => 465, 'auth' => true, 'username' => $username, 'password' => $password));
$headers = array('From' => '"lanlist.org" <mailer@lanlist.org>', 'To' => '<' . $recipient . '>', 'Subject' => $subject, 'Content-Type' => 'text/html');
$smtp->send('<' . $recipient . '>', $headers, $content);
ErrorHandler::getInstance()->beGreedy();
Logger::messageDebug('Sending email to ' . $recipient . ', subject: ' . $subject);
$sql = 'INSERT INTO email_log (subject, emailAddress, sent) VALUES (:subject, :emailAddress, now())';
$stmt = DatabaseFactory::getInstance()->prepare($sql);
$stmt->bindValue(':emailAddress', $recipient);
$stmt->bindValue(':subject', $subject);
$stmt->execute();
}
示例3: changePassword
public function changePassword($newPassword)
{
global $authBackend;
$sql = 'UPDATE users SET password = :password WHERE id = :id';
$stmt = DatabaseFactory::getInstance()->prepare($sql);
$stmt->bindValue(':id', $this->getElementValue('uid'));
$stmt->bindValue(':password', $authBackend->hashPassword($newPassword));
$stmt->execute();
echo 'password changed for uid: ' . $this->getElementValue('uid');
}
示例4: getAll
public function getAll()
{
$sql = 'SELECT a.* FROM finance_accounts a';
$stmt = DatabaseFactory::getInstance()->prepare($sql);
$stmt->execute();
$listAccounts = array();
foreach ($stmt->fetchAll() as $itemAccount) {
$accounts = new ItemFinanceAccount($itemAccount);
}
return $listAccounts;
}
示例5: __construct
public function __construct()
{
parent::__construct('formSendEmailToUser', 'Send email to user');
Session::requirePriv('SEND_EMAIL');
$uid = $_REQUEST['formSendEmailToUser-uid'];
$uid = intval($uid);
$this->user = User::getUserById($uid);
$sql = 'SELECT o.* FROM users u LEFT JOIN organizers o ON u.organization = o.id WHERE u.id = :userId LIMIT 1';
$stmt = DatabaseFactory::getInstance()->prepare($sql);
$stmt->bindValue(':userId', $this->user->getId());
$stmt->execute();
if ($stmt->numRows()) {
$this->organizer = $stmt->fetchRow();
} else {
$this->organizer = array('title' => '???', 'id' => '0');
}
$this->addElement(Element::factory('hidden', 'uid', null, $uid));
$this->addElement(Element::factory('text', 'email', 'Send to', $this->user->getData('email'), 'User: <a href = "viewUser.php?id=' . $this->user->getId() . '">' . $this->user->getData('username') . '</a> Organizer: <a href = "viewOrganizer.php?id=' . $this->organizer['id'] . '">' . $this->organizer['title'] . '</a>'));
$this->addElement(Element::factory('text', 'subject', 'Subject', 'Message from a human!'));
$this->addElement(Element::factory('textarea', 'body', 'Body', 'Hey ' . $this->user->getUsername() . ', ' . "\n\n" . 'Your message here.' . "\n\n- lanlist.org ", 'No footer will be appended. From: mailer@lanlist.org'));
$this->loadTemplate();
$this->addButtons(Form::BTN_SUBMIT);
}
示例6:
<?php
require_once 'includes/widgets/header.php';
$groupId = Sanitizer::getInstance()->filterUint('id');
$sql = 'SELECT g.id, g.title FROM groups g WHERE g.id = :id';
$stmt = DatabaseFactory::getInstance()->prepare($sql);
$stmt->bindValue(':id', $groupId);
$stmt->execute();
$tpl->assign('itemGroup', $stmt->fetchRow());
$sql = 'SELECT u.id, "secondary" as source, u.username FROM group_memberships m LEFT JOIN users u ON m.user = u.id WHERE m.group = :id1 UNION SELECT u.id, "primary" as source, u.username FROM users u WHERE u.group = :id2';
$stmt = DatabaseFactory::getInstance()->prepare($sql);
$stmt->bindValue(':id1', $groupId);
$stmt->bindValue(':id2', $groupId);
$stmt->execute();
$tpl->assign('listMembers', $stmt->fetchAll());
$sql = 'SELECT p.`key`, p.description FROM privileges_g gp LEFT JOIN permissions p ON gp.permission = p.id WHERE gp.group = :gid';
$stmt = DatabaseFactory::getInstance()->prepare($sql);
$stmt->bindValue(':gid', $groupId);
$stmt->execute();
$tpl->assign('listPrivileges', $stmt->fetchAll());
$tpl->display('viewGroup.tpl');
require_once 'includes/widgets/footer.php';