Пример #1
0
 /**
  * Search for symbols matching $symbol.
  *
  * @param string $symbol  The symbol name to search for.
  *
  * @return array  Any symids matching $symbol.
  */
 function searchSymbols($symbol)
 {
     $this->_connect();
     $query = 'SELECT symid, symid FROM luxor_symbols WHERE symname LIKE ?';
     $values = array($symbol . '%');
     return $this->_db->getAssoc($query, false, $values);
 }
Пример #2
0
 /**
  * Return a set of tag_ids, given the tag name
  *
  * @param array $names  An array of names to search for
  *
  * @return mixed  An array of tag_name => tag_ids | PEAR_Error
  */
 public function getTagIds($names)
 {
     if (empty($names)) {
         return array();
     }
     $sql = 'SELECT t.tag_name, t.tag_id FROM jonah_tags as t WHERE t.tag_name IN (' . implode(',', array_map(function ($v) {
         return '?';
     }, $names)) . ')';
     $tags = $this->_db->getAssoc($sql, false, $names);
     if ($tags instanceof PEAR_Error) {
         throw new Jonah_Exception($tags);
     }
     return $tags;
 }
Пример #3
0
 /**
  * Fetches all sends for one or more message ids.
  *
  * @access private
  * @param int|array  $message_id  The message id(s).
  *
  * @return mixed  The send id on success or PEAR Error on failure.
  */
 function _getSends($message_ids)
 {
     if (!is_array($message_ids)) {
         $message_ids = array($message_ids);
     }
     $sql = 'SELECT message_id, swoosh_sends.* FROM swoosh_sends' . ' WHERE message_id IN (' . str_repeat('?, ', count($message_ids) - 1) . '?)';
     $values = $message_ids;
     Horde::log('SQL Query by Hylax_Storage_sql::_getSends(): ' . $sql, 'DEBUG');
     $result = $this->_db->getAssoc($sql, false, $values, DB_FETCHMODE_ASSOC, true);
     if (is_a($result, 'PEAR_Error')) {
         Horde::log($result, 'ERR');
     }
     return $result;
 }
Пример #4
0
 /**
  * Get users by attributes
  */
 public function getUsers($criteria = array(), $from = 0, $count = 0)
 {
     $binds = $this->_buildWhere($criteria, false);
     if (!isset($criteria['sort_by'])) {
         $criteria['sort_by'] = $GLOBALS['prefs']->getValue('sort_by');
     }
     if (isset($criteria['sort_dir'])) {
         $criteria['sort_dir'] = $criteria['sort_dir'] ? 'ASC' : 'DESC';
     } else {
         $criteria['sort_dir'] = $GLOBALS['prefs']->getValue('sort_dir') ? 'ASC' : 'DESC';
     }
     $binds[0] = 'SELECT u.* ' . $binds[0] . ' ORDER BY u.' . $criteria['sort_by'] . ' ' . $criteria['sort_dir'];
     if ($count) {
         $binds[0] = $this->_db->modifyLimitQuery($binds[0], $from, $count);
     }
     return $this->_db->getAssoc($binds[0], false, $binds[1], DB_FETCHMODE_ASSOC);
 }
 public static function parseArguments($argv)
 {
     $mapinfo = Env::get('mapinfo');
     $cache = false;
     $args = self::arguments($argv);
     if (isset($args['game'])) {
         if (!isset($mapinfo[$args['game']])) {
             show::Event("ERROR", "Game: " . $args['game'] . " doesn't exists, escaping", 1);
             exit;
         }
         if (isset($args['map'])) {
             if (!isset($mapinfo[$args['game']][$args['map']])) {
                 show::Event("ERROR", "Game: " . $args['game'] . " Map: " . $args['map'] . " doesn't exists, escaping", 1);
                 exit;
             }
             $tmp[$args['game']][$args['map']] = $mapinfo[$args['game']][$args['map']];
             show::Event("ARGS", "--game=" . $args['game'], 2);
             show::Event("ARGS", "--map=" . $args['map'], 2);
         } else {
             $tmp[$args['game']] = $mapinfo[$args['game']];
             show::Event("ARGS", "--game=" . $args['game'], 2);
         }
     } else {
         $visible = '';
         $query = "SELECT code FROM hlstats_Games WHERE hidden='0'";
         $result = DB::doQuery($query);
         if (DB::numRows($result)) {
             while ($row = DB::getAssoc($result)) {
                 foreach ($row as $key => $val) {
                     if (isset($mapinfo[$val])) {
                         $visible .= "{$val}, ";
                         $tmp[$val] = $mapinfo[$val];
                     }
                 }
             }
         }
         show::Event("GAMES", substr($visible, 0, -2), 2);
     }
     if (isset($tmp)) {
         $mapinfo = $tmp;
     }
     if (isset($args['disablecache'])) {
         $cache = true;
         show::Event("ARGS", "--disable-cache=true", 2);
     } else {
         $cache = false;
         show::Event("ARGS", "--disable-cache=false", 2);
     }
     if (isset($args['ignoreinfected'])) {
         $ignore_infected = true;
         show::Event("ARGS", "--ignore-infected=true", 2);
     } else {
         $ignore_infected = false;
         show::Event("ARGS", "--ignore-infected=false", 2);
     }
     Env::set('mapinfo', $mapinfo);
     Env::set('disable_cache', $cache);
     Env::set('ignore_infected', $ignore_infected);
 }
Пример #6
0
 public function testGetAssoc()
 {
     $r = DB::getAssoc('select id,name from f**k limit 4');
     $this->assertTrue((bool) $r === true);
 }