当前位置: 首页>>代码示例>>PHP>>正文


PHP DatabaseFactory::getInstance方法代码示例

本文整理汇总了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();
 }
开发者ID:jamesread,项目名称:lanlist.org,代码行数:7,代码来源:EventsChecker.php

示例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();
}
开发者ID:jamesread,项目名称:lanlist.org,代码行数:27,代码来源:misc.php

示例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');
 }
开发者ID:jamesread,项目名称:lanlist.org,代码行数:10,代码来源:FormEditUser.php

示例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;
 }
开发者ID:CWFranklin,项目名称:lan-party-site,代码行数:11,代码来源:ListFinanceAccounts.php

示例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);
 }
开发者ID:jamesread,项目名称:lanlist.org,代码行数:23,代码来源:FormSendEmailToUser.php

示例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';
开发者ID:jamesread,项目名称:lanlist.org,代码行数:22,代码来源:viewGroup.php


注:本文中的DatabaseFactory::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。