示例#1
0
 /**
  * Instantiates the database connection
  *
  * @author Art <*****@*****.**>
  *
  * @param string $ip      The IP address to use
  * @param int    $port    The port to use
  * @param string $user    The username
  * @param string $pw      The password
  * @param string $db      The database to use
  * @param string $cache   Which cache interface to use
  * @param array  $options Connection options
  */
 function __construct($ip = ALO_MYSQL_SERVER, $port = ALO_MYSQL_PORT, $user = ALO_MYSQL_USER, $pw = ALO_MYSQL_PW, $db = ALO_MYSQL_DATABASE, $cache = ALO_MYSQL_CACHE, array $options = null)
 {
     $this->pdo = new PDO('mysql:dbname=' . $db . ';host=' . $ip . ';charset=' . ALO_MYSQL_CHARSET . ';port=' . $port, $user, $pw, $options);
     $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
     $this->cachePrefix = ALO_MYSQL_CACHE_PREFIX;
     parent::__construct($cache);
     \Log::debug('Initialised MySQL database connection');
 }
示例#2
0
 /**
  * Fetches a raw single-locale resultset
  *
  * @author Art <*****@*****.**>
  *
  * @param array  $pages  pages to fetch
  * @param string $locale Locale to fetch
  */
 protected function fetchOne(array $pages, $locale)
 {
     $params = [':first' => $locale];
     $sql = 'SELECT `key`,' . '`value` ' . 'FROM `alo_locale` ' . 'WHERE `lang`=:first';
     if (!ALO_LOCALE_FETCH_ALL) {
         $sql .= ' AND `page` IN (';
         foreach ($pages as $i => $p) {
             $sql .= ':p' . $i . ',';
             $params[':p' . $i] = $p;
         }
         $sql = rtrim($sql, ',') . ')';
     }
     $sql .= ' ORDER BY NULL';
     $this->raw = $this->db->prepQuery($sql, $params, self::$querySettings);
 }