/**
  * 构造函数
  *
  * @access public
  *
  * @param array $params 数据库连接参数,如主机名,数据库用户名,密码等
  *
  * @return boolean
  */
 public function __construct($options = null)
 {
     if (!extension_loaded('redis')) {
         Controller::halt('The redis extension to be loaded!');
     }
     //当参数为空时,程序则自动加载配置文件中数据库连接参数
     if (!$options || !is_array($options)) {
         $options = Configure::get('redis');
         if (!$options) {
             $options = array();
         }
     }
     $options += $this->_defaultOptions;
     //连接数据库
     $this->_Redis = new Redis();
     $connect = !$options['persistent'] ? 'connect' : 'pconnect';
     $return = $this->_Redis->{$connect}($options['host'], $options['port'], $options['expire']);
     if ($return && $options['password']) {
         $return = $this->_Redis->auth($options['password']);
     }
     if ($return && $options['database']) {
         $return = $this->_Redis->select($options['database']);
     }
     return $return;
 }
Example #2
0
 /**
  * 清空缓存
  * @param int $dbid 要清空的数据库(默认全部)
  */
 public static function clear($dbid = null)
 {
     if (is_null($dbid)) {
         self::$instance->flushAll();
     } else {
         self::$instance->select($dbid);
         self::$instance->flushDB();
     }
 }
Example #3
0
 /**
  * Get data with conditions from table
  * 
  * @param  mixed $condition 
  * @return array            
  */
 public function get($condition)
 {
     $raw = $this->db->select("*")->from($this->tableName);
     if (is_array($condition)) {
         $raw = $raw->where($condition);
     } else {
         $raw = $raw->where(array($this->primary => $condition));
     }
     $raw = $raw->exec();
     $fetched = $this->db->fetch($raw);
     return $fetched;
 }
 public function get_language_texts_list($lang_id = 1)
 {
     $this->fields_text = array_merge($this->fields_text, array("value_{$lang_id}"));
     $this->DB->select(implode(", ", $this->fields_text));
     $this->DB->from(LANG_TEXTS_TABLE);
     $results = $this->DB->get()->result_array();
     if (!empty($results) && is_array($results)) {
         $return = array();
         foreach ($results as $lang) {
             $return[$lang['gid']] = $lang['value_' . $lang_id];
         }
         return $return;
     }
     return array();
 }
Example #5
0
 /**
  * Remove data of available methods for moderators from data source by filters criteria
  * 
  * @param array $params filters criteria
  * @return void
  */
 public function delete_methods($params)
 {
     $this->DB->select('id')->from(AUSERS_MODERATE_METHODS_TABLE);
     if (isset($params["where"]) && is_array($params["where"]) && count($params["where"])) {
         foreach ($params["where"] as $field => $value) {
             $this->DB->where($field, $value);
         }
     }
     if (isset($params["where_in"]) && is_array($params["where_in"]) && count($params["where_in"])) {
         foreach ($params["where_in"] as $field => $value) {
             $this->DB->where_in($field, $value);
         }
     }
     if (isset($params["where_sql"]) && is_array($params["where_sql"]) && count($params["where_sql"])) {
         foreach ($params["where_sql"] as $value) {
             $this->DB->where($value);
         }
     }
     $results = $this->DB->get()->result_array();
     if (!empty($results) && is_array($results)) {
         foreach ($results as $r) {
             $this->delete_method($r["id"]);
         }
     }
     return;
 }
Example #6
0
 /**
  *	Contruir el control del typo pasado por parámetro
  *
  *	@param string 	Tipo de control HTML. select|password|checkbox|input
  *	@param string 	Nombre del control HTML. Etiqueta "name".
  *	@param string 	Valor inicial del control HTML. Etiqueta "value".
  *	@param array 	Atributos que se añaden a la etiqueta HTML del control.
  *	@param array 	Opciones para un control HTML de tipo "select".
  *
  *	@return Form
  */
 private function buildControl($type, $name, $value = null, $attributes = array(), $options = array())
 {
     switch ($type) {
         case 'select':
             //Agregar primero un valor vacio
             array_unshift($options, 'Seleccione un dato');
             //Campo tipo select
             return $this->form->select($name, $options, $value, $attributes);
         case 'password':
             //Campo tipo password
             return $this->form->password($name, $attributes);
         case 'checkbox':
             //Campo tipo checkbox
             return $this->form->checkbox($name);
         case 'textarea':
             //Campo tipo area de texto
             return $this->form->textarea($name, $value, $attributes);
         case 'hidden':
             //Campo tipo hidden
             return $this->form->hidden($name, $value);
         default:
             //Por defecto, campo tipo input
             return $this->form->input($type, $name, $value, $attributes);
     }
 }
 /**
  * @param object  $qb
  * @param boolean $inset
  * @param mixed   $values
  *
  * @return null
  *
  * @TODO Move this code
  */
 public function applyMassActionParameters($qb, $inset, $values)
 {
     if ($values) {
         $rootAlias = $qb->getRootAlias();
         $valueWhereCondition = $inset ? $qb->expr()->in($rootAlias, $values) : $qb->expr()->notIn($rootAlias, $values);
         $qb->andWhere($valueWhereCondition);
     }
     if (null !== $qb->getDQLPart('where')) {
         $whereParts = $qb->getDQLPart('where')->getParts();
         $qb->resetDQLPart('where');
         foreach ($whereParts as $part) {
             if (!is_string($part) || !strpos($part, 'entityIds')) {
                 $qb->andWhere($part);
             }
         }
     }
     $qb->setParameters($qb->getParameters()->filter(function ($parameter) {
         return $parameter->getName() !== 'entityIds';
     }));
     // Allows hydration as object.
     // Family mass edit operation receives an array instead of a Family object
     $qb->select($qb->getRootAlias());
     // remove limit of the query
     $qb->setMaxResults(null);
 }
Example #8
0
 /**
  * Test role synchronisation
  */
 public function testRoleSynchronisation()
 {
     // create a first test ACL role
     $query = $this->model->insert()->into('acl_role')->values(['name' => 'test role 1']);
     $statement = $this->model->prepareStatementForSqlObject($query);
     $statement->execute();
     $this->aclRolesIds[] = $this->model->getAdapter()->getDriver()->getLastGeneratedValue();
     // create a test user
     $query = $this->model->insert()->into('user_list')->values(['nick_name' => Rand::getString(32), 'email' => Rand::getString(32), 'role' => $this->aclRolesIds[0]]);
     $statement = $this->model->prepareStatementForSqlObject($query);
     $statement->execute();
     $this->usersIds[] = $this->model->getAdapter()->getDriver()->getLastGeneratedValue();
     // delete the created ACL role
     $query = $this->model->delete()->from('acl_role')->where(['id' => $this->aclRolesIds[0]]);
     $statement = $this->model->prepareStatementForSqlObject($query);
     $statement->execute();
     // fire the delete ACL role event
     AclEvent::fireDeleteAclRoleEvent($this->aclRolesIds[0]);
     // check the created test user's role
     $select = $this->model->select();
     $select->from('user_list')->columns(['role'])->where(['user_id' => $this->usersIds[0]]);
     $statement = $this->model->prepareStatementForSqlObject($select);
     $resultSet = new ResultSet();
     $result = $resultSet->initialize($statement->execute());
     // user must be a default member
     $this->assertEquals($result->current()['role'], AclBaseModel::DEFAULT_ROLE_MEMBER);
 }
Example #9
0
 /**
  * Return all types as array
  * @param boolean $status
  * @param array $filter_object_ids
  * @param boolean $formatted
  * @return array
  */
 public function get_types($status = false, $filter_object_ids = null, $formatted = true)
 {
     $this->DB->select(implode(", ", $this->fields));
     $this->DB->from(SPAM_TYPES_TABLE);
     if ($status) {
         $this->DB->where("status", "1");
     }
     if (is_array($filter_object_ids)) {
         foreach ($filter_object_ids as $value) {
             $this->DB->where_in("id", $value);
         }
     }
     $results = $this->DB->get()->result_array();
     if (!empty($results) && is_array($results)) {
         foreach ($results as $r) {
             $this->type_cache[$r['id']] = $this->type_cache[$r['gid']] = $data[$r['id']] = $r;
         }
         if ($formatted) {
             return $this->format_type($data);
         } else {
             return $data;
         }
     }
     return array();
 }
Example #10
0
 /**
  * Return alerts as array
  * @param array $params
  * @return integer
  */
 private function _get_alerts_count($params = null)
 {
     $this->DB->select("COUNT(*) AS cnt");
     $this->DB->from(SPAM_ALERTS_TABLE);
     if (isset($params["where"]) && is_array($params["where"]) && count($params["where"])) {
         foreach ($params["where"] as $field => $value) {
             $this->DB->where($field, $value);
         }
     }
     if (isset($params["where_in"]) && is_array($params["where_in"]) && count($params["where_in"])) {
         foreach ($params["where_in"] as $field => $value) {
             $this->DB->where_in($field, $value);
         }
     }
     if (isset($params["where_sql"]) && is_array($params["where_sql"]) && count($params["where_sql"])) {
         foreach ($params["where_sql"] as $value) {
             $this->DB->where($value);
         }
     }
     $results = $this->DB->get()->result_array();
     if (!empty($results) && is_array($results)) {
         return intval($results[0]["cnt"]);
     }
     return 0;
 }
 /**
  * Read
  *
  * Reads session data and acquires a lock
  *
  * @param	string	$session_id	Session ID
  * @return	string	Serialized session data
  */
 public function read($session_id)
 {
     if ($this->_get_lock($session_id) !== FALSE) {
         // Needed by write() to detect session_regenerate_id() calls
         $this->_session_id = $session_id;
         $this->_db->select('data')->from($this->_config['save_path'])->where('id', $session_id);
         if ($this->_config['match_ip']) {
             $this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
         }
         if (($result = $this->_db->get()->row()) === NULL) {
             // PHP7 will reuse the same SessionHandler object after
             // ID regeneration, so we need to explicitly set this to
             // FALSE instead of relying on the default ...
             $this->_row_exists = FALSE;
             $this->_fingerprint = md5('');
             return '';
         }
         // PostgreSQL's variant of a BLOB datatype is Bytea, which is a
         // PITA to work with, so we use base64-encoded data in a TEXT
         // field instead.
         $result = $this->_platform === 'postgre' ? base64_decode(rtrim($result->data)) : $result->data;
         $this->_fingerprint = md5($result);
         $this->_row_exists = TRUE;
         return $result;
     }
     $this->_fingerprint = md5('');
     return '';
 }
Example #12
0
 /**
  * 查询select
  *
  * @author          liu21st <*****@*****.**>
  * @lastmodify      2013-01-21 15:15:45 by mrmsl
  *
  * @param array $options 表达式参数
  *
  * @return mixed 查询成功,有数据,返回数据数组,否则返回空数组。查询失败,返回false
  *
  */
 public function select($options = array())
 {
     if (is_string($options) || is_numeric($options)) {
         //根据主键查询
         $pk = $this->getPk();
         $where[$pk] = strpos($options, ',') ? array('IN', $options) : $options;
         $options = array('where' => $where);
     } elseif (false === $options) {
         //用于子查询 不查询只返回SQL
         $options = $this->_parseOptions(array());
         //分析表达式
         return '(' . $this->_db->buildSelectSql($options) . ')';
     }
     $options = $this->_parseOptions($options);
     //分析表达式
     $result_set = $this->_db->select($options);
     if (false === $result_set) {
         return false;
     } elseif (empty($result_set)) {
         //查询结果为空
         return array();
     }
     $this->_afterSelect($result_set, $options);
     return $result_set;
 }
Example #13
0
 /**
  * Read
  * 读取
  * Reads session data and acquires a lock
  * 读取会话数据并获得一个锁
  * @param	string	$session_id	Session ID
  * @return	string	Serialized session data
  */
 public function read($session_id)
 {
     if ($this->_get_lock($session_id) !== FALSE) {
         // Needed by write() to detect session_regenerate_id() calls 需要写()来检测session_regenerate_id()调用
         $this->_session_id = $session_id;
         $this->_db->select('data')->from($this->_config['save_path'])->where('id', $session_id);
         if ($this->_config['match_ip']) {
             $this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
         }
         if (($result = $this->_db->get()->row()) === NULL) {
             $this->_fingerprint = md5('');
             return '';
         }
         // PostgreSQL's variant of a BLOB datatype is Bytea, which is a
         // PITA to work with, so we use base64-encoded data in a TEXT
         // field instead.
         // PostgreSQL的变体Bytea BLOB数据类型,这是一个皮塔饼,所以我们使用base64编码数据在一个文本字段。
         $result = $this->_platform === 'postgre' ? base64_decode(rtrim($result->data)) : $result->data;
         $this->_fingerprint = md5($result);
         $this->_row_exists = TRUE;
         return $result;
     }
     $this->_fingerprint = md5('');
     return '';
 }
Example #14
0
 /**
  * Return count of administrators by criteria
  * 
  * Available where clauses: where, where_in, where_sql etc.
  * 
  * @param array $params where clauses 
  * @param array $filter_object_ids filter by identificators
  * @return array
  */
 public function get_users_count($params = array(), $filter_object_ids = null)
 {
     $this->DB->select("COUNT(*) AS cnt");
     $this->DB->from(AUSERS_TABLE);
     if (isset($params["where"]) && is_array($params["where"]) && count($params["where"])) {
         foreach ($params["where"] as $field => $value) {
             $this->DB->where($field, $value);
         }
     }
     if (isset($params["where_in"]) && is_array($params["where_in"]) && count($params["where_in"])) {
         foreach ($params["where_in"] as $field => $value) {
             $this->DB->where_in($field, $value);
         }
     }
     if (isset($params["where_sql"]) && is_array($params["where_sql"]) && count($params["where_sql"])) {
         foreach ($params["where_sql"] as $value) {
             $this->DB->where($value);
         }
     }
     if (isset($filter_object_ids) && is_array($filter_object_ids) && count($filter_object_ids)) {
         $this->DB->where_in("id", $filter_object_ids);
     }
     $result = $this->DB->get()->result();
     if (!empty($result)) {
         return intval($result[0]->cnt);
     } else {
         return 0;
     }
 }
Example #15
0
 /**
  * Fetch a row
  *
  * The name of the resulting class is based on the table class name
  * eg <Mycomp>Table<Tablename> -> <Mycomp>Row<Tablename>
  *
  * @param	mixed	KDatabaseQuery object or query string, a row id or null for an empty row
  * @param	array	Options
  * @return	object 	KDatabaseRow object
  */
 public function fetchRow($query = null, array $options = array())
 {
     // fetch an empty row
     $options['table'] = $this;
     $options['base_path'] = array_key_exists('path', $options) ? $options['path'] : null;
     $component = $this->getClassName('prefix');
     $row = KInflector::singularize($this->getClassName('suffix'));
     $app = KFactory::get('lib.joomla.application')->getName();
     //Get the data and push it in the row
     if (isset($query)) {
         if (is_int($query)) {
             $key = $this->getPrimaryKey();
             $value = $query;
             //Create query object
             $query = $this->getDBO()->getQuery()->where($key, '=', $value);
         }
         if ($query instanceof KDatabaseQuery) {
             if (!count($query->columns)) {
                 $query->select('*');
             }
             if (!count($query->from)) {
                 $query->from($this->getTableName() . ' AS tbl');
             }
         }
         $this->_db->select($query, 0, 1);
         $options['data'] = (array) $this->_db->loadAssoc();
     }
     $row = KFactory::tmp($app . '::com.' . $component . '.row.' . $row, $options);
     return $row;
 }
 /**
  * Return number of filtered reason objects
  * @param array $params filters parameters
  * @param array $filter_object_ids filters identifiers
  * @return integer
  */
 public function get_product_count($params = array(), $filter_object_ids = null)
 {
     $this->DB->select("COUNT(*) AS cnt");
     $this->DB->from(PG_PRODUCTS_TABLE);
     if (isset($params["where"]) && is_array($params["where"]) && count($params["where"])) {
         foreach ($params["where"] as $field => $value) {
             $this->DB->where($field, $value);
         }
     }
     if (isset($params["where_in"]) && is_array($params["where_in"]) && count($params["where_in"])) {
         foreach ($params["where_in"] as $field => $value) {
             $this->DB->where_in($field, $value);
         }
     }
     if (isset($params["where_sql"]) && is_array($params["where_sql"]) && count($params["where_sql"])) {
         foreach ($params["where_sql"] as $value) {
             $this->DB->where($value);
         }
     }
     if (isset($filter_object_ids) && is_array($filter_object_ids) && count($filter_object_ids)) {
         $this->DB->where_in("id", $filter_object_ids);
     }
     $results = $this->DB->get()->result_array();
     if (!empty($results) && is_array($results)) {
         return intval($results[0]["cnt"]);
     }
     return 0;
 }
Example #17
0
 /**
  * 市区町村大字データを全て返却する
  *
  * @param   object  $dbh  DBリソース
  * @return  array   $data 都道府県情報
  */
 public static function getAddressAll($dbh)
 {
     $select = $dbh->select();
     $select->from(array('zip' => 'm_zipcode_01'), array("city" => "zip.city", "region" => "zip.region"));
     $select->where('zip.delete_flg = 0');
     $data = $select->query()->fetchAll();
     return $data;
 }
Example #18
0
 public function testMultiselected()
 {
     $expected = array('select' => array('name' => 'numbers[]', 'id' => 'Numbers', 'multiple' => 'multiple'), array('option' => array('value' => '1', 'selected' => 'selected')), 'first', '/option', array('option' => array('value' => '2')), 'second', '/option', array('option' => array('value' => '3', 'selected' => 'selected')), 'third', '/option', array('option' => array('value' => '4', 'selected' => 'selected')), 'fourth', '/option', '/select');
     $list = array(1 => 'first', 2 => 'second', 3 => 'third', 4 => 'fourth');
     $options = array('value' => array(1, 3, 4), 'multiple' => true);
     $result = $this->form->select('numbers', $list, $options);
     $this->assertTags($result, $expected);
 }
Example #19
0
 public function groupByCol($column)
 {
     try {
         return $this->db->select("SELECT * FROM `{$this->table}` GROUP BY {$column}");
     } catch (Exception $e) {
         return false;
     }
 }
Example #20
0
 /**
  * Configuramos la sesión
  * @param String $mode Modo (ID o Hash) a setear
  * @param Integer $value Valor a setear
  * @param Boolean $cookies Usamos cookies o no.
  * @return boolean
  */
 public static function set_id($value = null, $cookies = null)
 {
     $hash = $value !== null ? hash(self::$configuration['algorithm'], $value) : $_SESSION['hash'];
     $cookies = (bool) ($cookies !== null) ? $cookies : $_SESSION['use_cookies'];
     // De existir la sesión en la base de datos, la actualizamos. Èsto sólo
     // sucedería si el usuario ingresa desde otra computadora.
     $query = self::$db->select(self::$configuration['session_table'], '*', array('hash' => $hash));
     if ($query !== false and $query !== null) {
         if ($_SESSION['ip'] == $query['session_ip']) {
             if (self::$configuration['duration'] > $_SESSION['datetime'] - $query['session_datetime']) {
                 if (self::$db->update(self::$configuration['session_table'], array('session_datetime' => $_SESSION['datetime'], 'session_use_cookies' => $cookies), array('hash' => $_SESSION['hash'])) !== false) {
                     $result = self::SUCCESS;
                 } else {
                     $result = self::ERROR_SQL_UPDATE;
                 }
             } else {
                 $result = self::ERROR_TIMEOUT;
             }
         } else {
             $result = self::ERROR_UNRECOGNIZED_IP;
         }
     } else {
         // Seteamos una nueva sesión
         if (self::$db->insert(self::$configuration['session_table'], array('hash' => $hash, 'user_id' => $value, 'session_ip' => $_SESSION['ip'], 'session_datetime' => $_SESSION['datetime'], 'session_use_cookies' => $cookies)) !== false) {
             $result = self::SUCCESS;
         } else {
             $result = self::ERROR_SQL_INSERT;
         }
     }
     if ($result === self::SUCCESS) {
         $_SESSION['hash'] = $hash;
         $_SESSION['user_id'] = !isset($query['user_id']) ? $value : $query['user_id'];
         $_SESSION['datetime'] = time();
         $_SESSION['use_cookies'] = $cookies;
         self::set_user_object();
         if ($cookies === true) {
             setcookie(self::$configuration['cookie_name'], $_SESSION['hash'], time() + $configuration['cookie_life'], self::$configuration['cookie_path'], self::$configuration['cookie_domain']);
         }
         return true;
     } else {
         if ($result === self::ERROR_UNRECOGNIZED_IP or $result === self::ERROR_TIMEOUT or $result === self::ERROR_SQL_UPDATE) {
             self::end();
         }
         return false;
     }
 }
Example #21
0
 /**
  * Check messages owner is user
  * @param $message_ids set of messages
  * @param integer $user_id user identifier
  */
 public function is_user_messages($message_ids, $user_id)
 {
     if (empty($message_ids)) {
         return true;
     }
     $this->DB->select('COUNT(*) AS cnt')->where_in('id', (array) $message_ids)->where('id_user', $user_id);
     return $this->DB->count_all_results(MAILBOX_TABLE) == count((array) $message_ids);
 }
 /**
  * Get categories
  */
 public static function getCategories()
 {
     $categories = array();
     $_categories = MenuAdmin::$menu->select(null, 'all', null, array('category'));
     foreach ($_categories as $category) {
         $categories[] = $category['category'];
     }
     return array_unique($categories);
 }
Example #23
0
 /**
  * Garbage collect stale sessions from the SessionHandler backend.
  *
  * @param   integer  $maxlifetime  The maximum age of a session
  * @return  boolean  True on success, false otherwise
  */
 public function gc($maxlifetime)
 {
     $result = false;
     if ($this->getTable()->isConnected()) {
         $query = $this->getObject('lib:database.query.select')->where('time < :time')->bind(array('time' => (int) (time() - $maxlifetime)));
         $result = $this->_table->select($query, Database::FETCH_ROWSET)->delete();
     }
     return $result;
 }
Example #24
0
 /**
  * Check existing of hash
  *
  * @static
  * @param string $hash
  * @param object $db
  * @param string $table
  * @return bool
  */
 protected static function _isNotExist($hash, $db, $table)
 {
     $select = $db->select()->from($table)->where('hash=?', $hash);
     $records = $db->fetchAll($select);
     if (empty($records)) {
         return true;
     }
     return false;
 }
Example #25
0
 /**
  * Retourne, sous forme de recordset, la liste des logs admin.
  *
  * @param array $aParams Paramètres de requete
  * @return recordset
  */
 public function getLogs($aParams = array(), $bCountOnly = false)
 {
     $reqPlus = '';
     $reqWhere = '';
     if (!empty($aParams['id'])) {
         $reqPlus .= ' AND id=' . (int) $aParams['id'] . ' ';
     }
     if (!empty($aParams['user_id'])) {
         $reqPlus .= ' AND user_id=' . (int) $aParams['user_id'] . ' ';
     }
     if (!empty($aParams['username'])) {
         $reqPlus .= ' AND username=\'' . $this->db->escapeStr($aParams['username']) . '\' ';
     }
     if (!empty($aParams['component'])) {
         $reqPlus .= ' AND component=\'' . $this->db->escapeStr($aParams['component']) . '\' ';
     }
     if (!empty($aParams['ip'])) {
         $reqPlus .= ' AND ip=\'' . $this->db->escapeStr($aParams['ip']) . '\' ';
     }
     if (isset($aParams['type']) && array_key_exists($aParams['type'], self::getTypes())) {
         $reqPlus .= ' AND type=' . (int) $aParams['type'] . ' ';
     } else {
         $reqPlus .= ' ';
     }
     if (isset($aParams['code']) && array_key_exists($aParams['code'], self::getCodes())) {
         $reqPlus .= ' AND code=' . (int) $aParams['code'] . ' ';
     }
     if (!empty($aParams['date_max']) && !empty($aParams['date_min'])) {
         $reqPlus .= ' AND date BETWEEN \'' . date('Y-m-d H:i:s', strtotime($aParams['date_min'])) . '\' AND \'' . date('Y-m-d H:i:s', strtotime($aParams['date_max'])) . '\' ';
     } elseif (!empty($aParams['date_min'])) {
         $reqPlus .= ' AND date > \'' . date('Y-m-d H:i:s', strtotime($aParams['date_min'])) . '\' ';
     } elseif (!empty($aParams['date_max'])) {
         $reqPlus .= ' AND date < \'' . date('Y-m-d H:i:s', strtotime($aParams['date_max'])) . '\' ';
     }
     if ($bCountOnly) {
         $query = 'SELECT COUNT(id) AS num_logs_admin ' . 'FROM ' . $this->t_log . ' ' . 'WHERE 1 ' . $reqPlus;
     } else {
         $query = 'SELECT id, user_id, username, ip, date, type, component, code, message ' . 'FROM ' . $this->t_log . ' ' . 'WHERE 1 ' . $reqPlus;
         if (!empty($aParams['order'])) {
             $query .= 'ORDER BY ' . $aParams['order'] . ' ' . $aParams['order_direction'] . ' ';
         } else {
             $query .= 'ORDER BY date DESC ';
         }
         if (!empty($aParams['limit'])) {
             $query .= 'LIMIT ' . $aParams['limit'] . ' ';
         }
     }
     if (($rs = $this->db->select($query)) === false) {
         return new recordset(array());
     }
     if ($bCountOnly) {
         return (int) $rs->num_logs_admin;
     } else {
         return $rs;
     }
 }
Example #26
0
 /**
  * Get the total amount of items
  *
  * @return  int
  */
 public function getTotal()
 {
     // Get the data if it doesn't already exist
     if (!isset($this->_total)) {
         $query = $this->_buildCountQuery();
         $this->_db->select($query);
         $this->_total = $this->_db->loadResult();
     }
     return parent::getTotal();
 }
 /**
  * Check promo object is exists by language
  * 
  * @param integer $id_lang language identifier
  * @return boolean
  */
 public function exists_promo($id_lang)
 {
     $this->DB->select('COUNT(*) AS cnt')->from(CONTENT_PROMO_TABLE)->where('id_lang', $id_lang);
     $result = $this->DB->get()->result();
     if (!empty($result) && intval($result[0]->cnt) > 0) {
         return true;
     } else {
         return false;
     }
 }
Example #28
0
 /**
  * Get link type by GID
  * @param string $type_gid
  * @return mixed
  */
 public function get_type_by_gid($type_gid)
 {
     $type_gid = preg_replace("/[^a-z_]/", "", strtolower($type_gid));
     if (!$type_gid) {
         return false;
     }
     $this->DB->select('id, gid, separated, lifetime, unique_type');
     $this->DB->from(LINKER_TYPES_TABLE);
     $this->DB->where('gid', $type_gid);
     //_compile_select;
     $result = $this->DB->get()->result();
     if (!empty($result)) {
         $rt = get_object_vars($result[0]);
         $rt["table_name"] = $rt["separated"] ? LINKER_SEPARATED_PREFIX . $rt["gid"] : LINKER_TABLE;
         return $rt;
     } else {
         return false;
     }
 }
Example #29
0
 /**
  * List System Variable Keys
  * Return array of variable keys or FALSE
  * @return bool|array , FALSE if var is not set, the value of var if set
  */
 public function list_system_var_keys()
 {
     $query = $this->aauth_db->select('key');
     $query = $this->aauth_db->get($this->config_vars['system_variables']);
     // if variable not set
     if ($query->num_rows() < 1) {
         return FALSE;
     } else {
         return $query->result();
     }
 }
Example #30
0
 /**
  * Return data of module by GUID
  * 
  * @param string $module_gid module guid
  * @return array
  */
 public function get_module($module_gid)
 {
     $this->DB->select(implode(", ", $this->module_attrs))->from(AVIARY_MODULES_TABLE)->where("module_gid", $module_gid);
     $result = $this->DB->get()->result_array();
     if (!empty($result)) {
         $return = $result[0];
     } else {
         $return = array();
     }
     return $return;
 }