コード例 #1
0
ファイル: delete.php プロジェクト: robchett/framework
 /**
  * @return \PDOStatement
  */
 public function execute()
 {
     $query = 'DELETE FROM ' . $this->table . $this->get_filters();
     compiler::break_cache($this->table);
     cache::break_cache($this->table);
     return _db::query($query, $this->parameters);
 }
コード例 #2
0
ファイル: update.php プロジェクト: robchett/framework
 public function execute()
 {
     $query = 'UPDATE ' . $this->table . ' SET ' . $this->get_values() . $this->get_filters();
     compiler::break_cache($this->table);
     cache::break_cache($this->table);
     return _db::query($query, $this->parameters);
 }
コード例 #3
0
ファイル: replace.php プロジェクト: robchett/framework
 public function execute()
 {
     $query = 'REPLACE INTO ' . $this->table . ' SET ' . $this->get_values();
     _db::query($query, $this->parameters);
     $id = _db::insert_id();
     compiler::break_cache($this->table);
     cache::break_cache($this->table);
     return $id;
 }
コード例 #4
0
ファイル: table_array.php プロジェクト: robchett/framework
 /**
  * @param string $class
  * @param array $fields_to_retrieve
  * @param array $options
  */
 public function get_all($class, array $fields_to_retrieve, $options = [])
 {
     $this->fields = $fields_to_retrieve;
     $this->options = $options;
     $this->class = $class;
     /** @var table $obj */
     $obj = new $class();
     $links = [];
     $mlinks = [];
     $obj->set_default_retrieve($fields_to_retrieve, $options);
     table::organise_links($obj, $fields_to_retrieve, $links, $mlinks);
     $dependencies = [get::__class_name($class)];
     foreach ($links as $module => $link_info) {
         $field = $link_info['field'];
         $retrieves = $link_info['retrieve'];
         $dependencies[] = get::__class_name($module);
         $options['join'][$module] = $module . '.' . $field->field_name . '=' . $obj->class_name() . '.' . $field->field_name;
         foreach ($retrieves as $retrieve) {
             $fields_to_retrieve[] = $module . '.' . $retrieve;
         }
     }
     $key = 'get_all_' . $class . '_fetch_' . implode(',', $fields_to_retrieve) . '_options_' . serialize($options);
     $elements = \classes\cache::grab($key, function () use($class, $fields_to_retrieve, $options, $links, $mlinks, $obj) {
         if (!isset($options['order'])) {
             $options['order'] = get::__class_name($class) . '.position';
         }
         $select = _db::get_query($class, $fields_to_retrieve, $options);
         $res = $select->execute();
         if (_db::num($res)) {
             $row = _db::fetch($res, null);
             $mappings = $obj->get_field_mappings(array_keys($row));
             do {
                 /** @var table $class */
                 $object = new $class();
                 $object->set_from_row($row, $links, $mappings);
                 foreach ($mlinks as $module => $blah) {
                     $object->{$module . '_elements'} = new \classes\table_array();
                     $object->{$module} = new _collection();
                 }
                 $this[] = $object;
             } while ($row = _db::fetch($res, null));
         }
         $this->reset_iterator();
         foreach ($mlinks as $module => $link_info) {
             /** @var \form\field_link $field */
             $field = $link_info['field'];
             $retrieves = $link_info['retrieve'];
             $retrieves[] = 'l.' . $obj->get_primary_key_name() . ' AS linked_id';
             $sub_class = $field->get_link_object();
             $classes = $sub_class::get_all($retrieves, ['join' => [get::__class_name($class) . '_link_' . get::__class_name($sub_class) . ' l' => 'l.link_' . $sub_class->get_primary_key_name() . '=' . get::__class_name($sub_class) . '.' . $sub_class->get_primary_key_name()], 'where' => 'l.' . $obj->get_primary_key_name() . ' IN(' . implode(',', $this->get_table_keys()) . ')']);
             /** @var table $sub_object */
             foreach ($classes as $sub_object) {
                 $object = $this->find_table_key($sub_object->linked_id);
                 if ($object) {
                     $object->{$module . '_elements'}->push($sub_object);
                     $object->{$module}->push($sub_object->get_primary_key());
                 }
             }
         }
         return $this->exchangeArray([]);
     }, $dependencies);
     $this->exchangeArray($elements);
 }
コード例 #5
0
ファイル: auto_loader.php プロジェクト: robchett/framework
 public function __destruct()
 {
     \classes\cache::set(['autoloader.file_paths' => static::$file_paths], ['autoloader']);
 }
コード例 #6
0
ファイル: cache.php プロジェクト: robchett/framework
 public static function default_connection()
 {
     _cache::connect(ini::get('memcached', 'instance'), ini::get('memcached', 'server'), ini::get('memcached', 'port'));
 }