예제 #1
0
파일: DBSimple.php 프로젝트: gudwin/extasy
 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;
 }
예제 #2
0
파일: data_list.php 프로젝트: gudwin/extasy
 /**
  *   Возвращает все элементы указанного типа
  * @return
  */
 protected function selectItem()
 {
     $orderBy = '';
     if (!empty($this->typeInfo['order'])) {
         $orderBy = trim($this->typeInfo['order']);
     }
     return DBSimple::select($this->typeInfo['table'], null, $orderBy);
 }
예제 #3
0
파일: testModel.php 프로젝트: gudwin/extasy
 /**
  *
  * @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;
 }
예제 #4
0
파일: Log.php 프로젝트: gudwin/extasy
 public static function selectAll()
 {
     $data = DBSimple::select(self::tableName, null, 'name asc');
     $result = array();
     foreach ($data as $row) {
         $result[] = new Log($row);
     }
     return $result;
 }
예제 #5
0
 /**
  * @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;
 }
예제 #6
0
파일: Latests.php 프로젝트: gudwin/extasy
 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;
 }
예제 #7
0
파일: cconfig.php 프로젝트: gudwin/extasy
 /**
  * Возвращает все существующие схемы
  */
 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;
 }
예제 #8
0
 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();
 }
예제 #9
0
파일: misc.php 프로젝트: gudwin/extasy
 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;
 }
예제 #10
0
파일: Cleaner.php 프로젝트: gudwin/extasy
 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);
     }
 }
예제 #11
0
 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;
 }
예제 #12
0
function selectMessages($category)
{
    return DBSimple::select('cms_log', array('category' => $category), 'id asc');
}
예제 #13
0
파일: HasMany.php 프로젝트: gudwin/extasy
 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];
     }
 }
예제 #14
0
 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']));
 }