本文整理汇总了PHP中DatabaseFactory类的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseFactory类的具体用法?PHP DatabaseFactory怎么用?PHP DatabaseFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DatabaseFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$this->headerFooter = HeaderFooterFactory::createHeaderFooter();
$this->pageHome = PageFactory::createHome();
$this->database = DatabaseFactory::createDatabase();
$this->file = FileFactory::setFile();
}
示例2: GetInstance
public static function GetInstance()
{
static $instance = null;
if (is_null($instance)) {
$factory = new DatabaseFactory();
$instance = $factory->createObject(G_DB_TYPE);
if (is_null($instance)) {
die("Can not create database object\n");
}
}
return $instance;
}
示例3: getOutData
public function getOutData()
{
$id = $this->data;
$query = "SELECT * FROM Users WHERE id = {$id}";
$db = DatabaseFactory::create("AAADatabase")->connect();
return $db->SQLFetchArray($query);
}
示例4: getOutData
public function getOutData()
{
$date = $this->data['date'];
$db = DatabaseFactory::create("SquidDatabase")->connect();
$rowsTotalNumberInArray = $db->SQLFetchArray("SELECT COUNT(*)\n FROM SquidData\n WHERE date = '{$date}' ");
return (int) $rowsTotalNumberInArray['COUNT(*)'];
}
示例5: selectgen
public static function selectgen($name, $label, $table, $required = null, $selected = null)
{
if ($required != null) {
$required = 'required';
}
$s = '';
$s .= '<div class="form-group">
<label>' . $label . '</label>
<select class="form-control" name="' . $name . '" required >';
$s .= '<option value="" > Select </option>';
$pdo = DatabaseFactory::getFactory()->getConnection();
$sql = "SELECT id, name FROM " . $table;
$query = $pdo->prepare($sql);
$query->execute();
$options = $query->fetchAll();
foreach ($options as $k => $v) {
$s .= '<option value="' . $v->id . '" ';
if ($v->id == $selected) {
$s .= ' selected ';
}
$s .= ' >' . $v->name . '</option>';
}
$s .= '</select>
</div>';
return $s;
}
示例6: register_on_db
private function register_on_db($cinema)
{
//o nome da classe é o id do banco, recupera dinamico
$classname = get_class($this);
$cinema->_id = $classname;
$db = DatabaseFactory::get_provider();
$cinema_db = $db->find($classname);
if ($cinema_db) {
if ($cinema_db->hash != $cinema->hash) {
$cinema->_rev = $cinema_db->_rev;
//utilizado mais para ter uma nocao olhando direto no banco...
$cinema->last_update = date('d/m/y H:i:s');
$db->save($cinema);
//atributo utilizado para filtrar cinemas que foram atualizados para notificar clientes de atualizacao uma unica vez.
//seta o valor temporariamente, não guarda no db, so para validacao
$cinema->updated = 'YES';
//Log::write($cinema->name . ' tem novidades');
}
} else {
$cinema->last_update = date('d/m/y H:i:s');
$db->save($cinema);
$cinema->updated = 'YES';
}
if (!isset($cinema->updated)) {
//controle so de validacao
$cinema->updated = 'NO';
}
return $cinema;
}
示例7: lookup_member
public static function lookup_member($id = null, $email = null)
{
$id = (int) $id;
$email = trim($email);
$sql = "SELECT `AutoID` , `useremail`, `userFirstname`, `userLastname` FROM `user_signup`";
if ($id || $email || $author) {
$sql .= " WHERE";
} else {
return null;
}
if ($id) {
$sql .= " `AutoID` = '{$id}'";
if ($email || $author) {
$sql .= " &&";
}
}
if ($email) {
$sql .= " `useremail` = '{$email}'";
}
if ($res = DatabaseFactory::passinggreen_master_db()->query($sql)) {
if ($res->num_rows == 1) {
$member = $res->fetch_object();
return new Member($member->AutoID);
} else {
return null;
}
}
return null;
}
示例8: getFactory
public static function getFactory()
{
if (!self::$factory) {
self::$factory = new DatabaseFactory();
}
return self::$factory;
}
示例9: getOutData
public function getOutData()
{
$date = $this->data['date'];
$query = "SELECT client_ip, COUNT(client_ip) as frequency \n FROM SquidData \n \t\t\tWHERE date = '{$date}'\n GROUP BY client_ip \n \t\t\tORDER BY frequency DESC";
$db = DatabaseFactory::create("SquidDatabase")->connect();
return $db->SQLFetchAllArray($query);
}
示例10: getOutData
public function getOutData()
{
$name = $this->data;
$query = "SELECT * FROM Users WHERE name LIKE '%{$name}%'";
$db = DatabaseFactory::create("AAADatabase")->connect();
return $db->SQLFetchAllArray($query);
}
示例11: getOutData
public function getOutData()
{
$id = $this->data;
$query = "SELECT roles.*, 1 as status\n FROM roles \n LEFT JOIN users_roles\n ON users_roles.role_id = roles.id\n WHERE users_roles.user_id = {$id}\n\n\t\t\t\t UNION\n\n\t\t\t\t SELECT roles.*, 0 as status\n FROM roles \n WHERE roles.id NOT IN \n (\n \tSELECT roles.id\n\t\t\t \tFROM roles\n\t\t \t \tLEFT JOIN users_roles\n\t\t \tON users_roles.role_id = roles.id\n\t\t \tWHERE users_roles.user_id = {$id}\n\t\t )";
$db = DatabaseFactory::create("AAADatabase")->connect();
return $db->SQLFetchAllArray($query);
}
示例12: setInData
public function setInData($data)
{
$id = $data;
$query = "DELETE FROM Users WHERE id={$id}";
$db = DatabaseFactory::create("AAADatabase")->connect();
$db->SQLQuery($query);
}
示例13: 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();
}
示例14: 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();
}
示例15: getOutData
public function getOutData()
{
$actionName = $this->data;
$query = "SELECT roles.*\n FROM roles\n LEFT JOIN roles_actions\n ON roles_actions.role_id = roles.id\n WHERE roles_actions.action_name = '{$actionName}'";
$db = DatabaseFactory::create("AAADatabase")->connect();
return $db->SQLFetchAllArray($query);
}