public static function select($table, $where = '', $order = '') { Trace::addMessage(__CLASS__, sprintf('Select from table:"%s" with condition:"%s" and order:"%s"', $table, print_r($where, true), $order)); $result = parent::select($table, $where, $order); Trace::addMessage(__CLASS__, 'Finished selecting from: ' . $table); return $result; }
/** * Возвращает все элементы указанного типа * @return */ protected function selectItem() { $orderBy = ''; if (!empty($this->typeInfo['order'])) { $orderBy = trim($this->typeInfo['order']); } return DBSimple::select($this->typeInfo['table'], null, $orderBy); }
/** * * @return multitype:extasyTestModel */ public static function selectAll() { $list = DBSimple::select(self::getTableName(), '', '`id` asc'); $result = array(); foreach ($list as $key => $row) { $result[] = new extasyTestModel($row); } return $result; }
public static function selectAll() { $data = DBSimple::select(self::tableName, null, 'name asc'); $result = array(); foreach ($data as $row) { $result[] = new Log($row); } return $result; }
/** * @return Job[] */ public function getLatests($limit) { $orderCond = sprintf('id desc limit 0,%d', $limit); $data = DBSimple::select(self::TableName, [], $orderCond); foreach ($data as $key => $row) { $job = Job::factory($row); $data[$key] = $job; } return $data; }
protected function action() { $orderCond = sprintf('id desc limit 0,%d', $this->limit); $data = DBSimple::select(Job::TableName, [], $orderCond); foreach ($data as $key => $row) { $job = Job::factory($row); $data[$key] = $job->getPreviewParseData(); } return $data; }
/** * Возвращает все существующие схемы */ public static function selectAll() { $table = CCONFIG_SCHEMA_TABLE; $data = DBSimple::select($table, '', '`title`'); $result = array(); foreach ($data as $row) { // Создаем объект на основе схемы $result[] = new CConfigSchema($row); } return $result; }
protected function getGroupSelectbox() { $rights = DBSimple::select(ACL_TABLE, 'parentId = 0', '`fullPath` asc'); foreach ($rights as $key => $row) { $rights[$key] = ['id' => $row['fullPath'], 'name' => $row['fullPath']]; } array_unshift($rights, ['id' => 0, 'name' => 'Не выбрано']); $control = new \CSelect(); $control->name = 'group'; $control->values = $rights; return $control->generate(); }
public static function export($parentId = 0) { $parentId = IntegerHelper::toNatural($parentId); $result = array(); $data = DBSimple::select(ACL_TABLE, "parentId = '{$parentId}'", '`name` ASC'); foreach ($data as $row) { $children = self::export($row['id']); $add = array('id' => $row['id'], 'name' => $row['name'], 'title' => $row['title'], 'fullPath' => $row['fullPath']); if (!empty($children)) { $add['children'] = $children; } $result[] = $add; } return $result; }
protected static function storeExtraRecords() { \CMSLog::addMessage(__CLASS__, 'Cleaning log table'); $found = DBSimple::select(Record::tableName, array(), sprintf('id desc limit %d,1', self::$maximumLogLength)); if (empty($found)) { return; } $data = DBSimple::select(Record::tableName, '1', sprintf('id asc limit 0,%d', self::$maximumLogLength)); if (!empty($data)) { $lastId = $data[sizeof($data) - 1]['id']; $fileName = sprintf('%s%s%s.log', SYS_ROOT, self::OutputDir, date('Y-m-d H:i:s')); file_put_contents($fileName, json_encode($data)); DBSimple::delete(Record::tableName, array(sprintf('id <= %d', $lastId))); \CMSLog::addMessage(__CLASS__, 'Extra messages exported in local folder: ' . $fileName); } }
protected function autoloadValue() { $networks = DBSimple::select(Network::TableName); $personalTokens = DBSimple::select(self::UIDTable, array('user_id' => $this->document->id->getValue())); $map = []; $newValue = []; foreach ($networks as $row) { $map[$row['id']] = $row; } foreach ($personalTokens as $row) { if (!isset($map[$row['network_id']])) { throw new \NotFoundException('Unknown social network. Value - ' . $row['network_id']); } $network = $map[$row['network_id']]; $newValue[$network['name']] = $row['uid']; } $this->aValue = $newValue; }
function selectMessages($category) { return DBSimple::select('cms_log', array('category' => $category), 'id asc'); }
protected function loadData() { $data = DBSimple::select($this->tableName, array($this->innerKey => $this->document->id->getValue()), 'id asc'); $this->aValue = array(); foreach ($data as $row) { $this->aValue[] = $row[$this->foreighnKey]; } }
protected static function removeChild($el) { // Получаем дочерние элементы $childList = DBSimple::select(ACL_TABLE, array('parentId' => $el['id'])); foreach ($childList as $row) { // Вызов удаления для дочерних self::removeChild($row); } // Удаляем гранты на текущие элементы DBSimple::delete(ACL_GRANT_TABLE, array('actionId' => $el['id'])); // Удаляем саму запись DBSimple::delete(ACL_TABLE, array('id' => $el['id'])); }