本文整理汇总了PHP中ConnectionFactory类的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionFactory类的具体用法?PHP ConnectionFactory怎么用?PHP ConnectionFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConnectionFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatch
public function dispatch()
{
$connection = ConnectionFactory::getDataConnection();
$bookmarks = $connection->getBookmarks();
$template = new BookmarksTemplate($bookmarks, "Bookmarks");
$template->showTemplate();
}
示例2: check
public function check()
{
$this->setView('reclaim/index');
if (Session::isLoggedIn()) {
return Error::set('You\'re logged in!');
}
$this->view['valid'] = true;
$this->view['publicKey'] = Config::get('recaptcha:publicKey');
if (empty($_POST['recaptcha_challenge_field']) || empty($_POST['recaptcha_response_field'])) {
return Error::set('We could not find the captcha validation fields!');
}
$recaptcha = Recaptcha::check($_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
if (is_string($recaptcha)) {
return Error::set(Recaptcha::$errors[$recaptcha]);
}
if (empty($_POST['username']) || empty($_POST['password'])) {
return Error::set('All forms are required.');
}
$reclaims = new reclaims(ConnectionFactory::get('mongo'));
$good = $reclaims->authenticate($_POST['username'], $_POST['password']);
if (!$good) {
return Error::set('Invalid username/password.');
}
$reclaims->import($_POST['username'], $_POST['password']);
$users = new users(ConnectionFactory::get('mongo'));
$users->authenticate($_POST['username'], $_POST['password']);
header('Location: ' . Url::format('/'));
}
示例3: handler
public static function handler($data = null)
{
if (isset($_SESSION['done_autoauth'])) {
return;
}
if (empty($_SERVER['SSL_CLIENT_RAW_CERT'])) {
return self::done();
}
if (Session::isLoggedIn()) {
return self::done();
}
$certs = new certs(ConnectionFactory::get('mongo'), ConnectionFactory::get('redis'));
$userId = $certs->check($_SERVER['SSL_CLIENT_RAW_CERT']);
if ($userId == NULL) {
return self::done();
}
$users = new users(ConnectionFactory::get('mongo'));
$user = $users->get($userId, false);
if (empty($user)) {
return;
}
if (!in_array('autoauth', $user['auths'])) {
return self::done();
}
if ($user['status'] == users::ACCT_LOCKED) {
return self::done();
}
Session::setBatchVars($user);
return self::done();
}
示例4: getModel
private static function getModel()
{
if (empty(self::$missions)) {
self::$missions = new missions(ConnectionFactory::get('mongo'));
}
return self::$missions;
}
示例5: basic
public function basic($arguments)
{
$missions = new missions(ConnectionFactory::get('mongo'));
if (!empty($arguments[0])) {
// A specific mission has been requested.
$mission = $missions->get('basic', intval($arguments[0]));
if (empty($mission)) {
return Error::set('Mission does not exist.');
}
$this->view['valid'] = true;
$this->view['num'] = $arguments[0];
$this->view['basic'] = new BasicMissions();
$this->view['name'] = $mission['name'];
$this->view['next'] = $arguments[0] != 6;
$good = call_user_func(array($this->view['basic'], 'validateMission' . $this->view['num']));
if ($good !== null) {
// BALANCED. TERNARY.
if (!$good) {
return Error::set('Wrong!');
}
$this->view['valid'] = false;
$this->view['good'] = true;
}
} else {
// Just show a listing of possible missions.
$this->view['valid'] = true;
$this->view['missions'] = $missions->getMissionsByType('basic');
$this->setView('missions/base');
}
}
示例6: index
public function index($arguments)
{
$news = new news(ConnectionFactory::get('mongo'));
$articles = new articles(ConnectionFactory::get('mongo'));
$notices = new notices(ConnectionFactory::get('redis'));
$irc = new irc(ConnectionFactory::get('redis'));
$quotes = new quotes(ConnectionFactory::get('mongo'));
$forums = new forums(ConnectionFactory::get('redis'));
// Set all site-wide notices.
foreach ($notices->getAll() as $notice) {
Error::set($notice, true);
}
// Fetch the easy data.
$this->view['news'] = $news->getNewPosts();
$this->view['shortNews'] = $news->getNewPosts(true);
$this->view['newArticles'] = $articles->getNewPosts('new', 1, 5);
$this->view['ircOnline'] = $irc->getOnline();
$this->view['randomQuote'] = $quotes->getRandom();
$this->view['fPosts'] = $forums->getNew();
// Get online users.
$apc = new APCIterator('user', '/' . Cache::PREFIX . 'user_.*/');
$this->view['onlineUsers'] = array();
while ($apc->valid()) {
$current = $apc->current();
array_push($this->view['onlineUsers'], substr($current['key'], strlen(Cache::PREFIX) + 5));
$apc->next();
}
// Set title.
Layout::set('title', 'Home');
}
示例7: getInstance
public static function getInstance()
{
if (!self::$instance) {
self::$instance = new ConnectionFactory();
}
return self::$instance;
}
示例8: parseFavouriteSites
/**
* Retrieve favourite sites and fill data in template.
*/
private function parseFavouriteSites($template)
{
try {
$connection = ConnectionFactory::getDataConnection();
$favourites = $connection->getWebsiteFavourites();
foreach ($favourites as $id => $favourite) {
$name = $favourite->getName();
$link = SERVER_HOST_AND_PATH . "php/scraper" . $favourite->getLink();
switch ($favourite->getType()) {
case "movie":
$template->setFavouriteMovieWebsite(array($name, $link));
break;
case "serie":
$template->setFavouriteSerieWebsite(array($name, $link));
break;
case "documentary":
$template->setFavouriteDocumentaryWebsite(array($name, $link));
break;
case "anime":
$template->setFavouriteAnimeWebsite(array($name, $link));
break;
}
}
} catch (Exception $e) {
//Ignored exception
}
}
示例9: createConnection
/**
* Searches for the configuration for the connection and creates it. If the configuration is not found then it will
* return NULL
*
* @param string $name
* @return null|\PDO
*/
protected function createConnection($name)
{
if (!isset($this->config[$name]['pdo'])) {
return null;
}
return ConnectionFactory::factory($this->config[$name]['pdo']);
}
示例10: transactionIdExists
public static function transactionIdExists($transaction_id)
{
$conditions = array();
$conditions['transaction_id'] = $transaction_id;
$success = ConnectionFactory::SelectValue("transaction_id", "diamond_purchased_history", $conditions);
return $success;
}
示例11: getFactory
public static function getFactory()
{
if (!self::$factory) {
self::$factory = new ConnectionFactory();
}
return self::$factory;
}
示例12: queryAllSelect
public function queryAllSelect()
{
$sql = "SELECT id_area, nome FROM {$this->table}";
$stmt = ConnectionFactory::prepare($sql);
$stmt->execute();
return $stmt->fetchAll();
}
示例13: getInstance
/**
* Retorna um objeto da classe ConnectionFactory
* @return ConnectionFactory object
*/
public static function getInstance()
{
if (!isset(self::$instance)) {
$c = __CLASS__;
self::$instance = new $c();
}
return self::$instance;
}
示例14: update
/**
* atualiza um registro da tabela
*
* @parametro TematicaMySql tematica
*/
public function update(Log $log)
{
$sql = "UPDATE {$this->table} SET tabela = :tabela, acao = :acao, descricao=:descricao WHERE id_log = :id";
$id = $log->getIdLog();
$stmt = ConnectionFactory::prepare($sql);
$stmt->bindParam(':id_log', $id);
return $stmt->execute();
}
示例15: queryAllAreaAvaliador
public function queryAllAreaAvaliador($id)
{
$sql = "SELECT aa.fk_area as area FROM area a JOIN avaliador_area aa ON a.id_area = aa.fk_area AND fk_avaliador = :id";
$stmt = ConnectionFactory::prepare($sql);
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
$stmt->execute();
return $stmt->fetch();
}