public function __init() { $q1 = new Database_Query(); // $q1->insert("names", DB_IGNORE)->set('name','test1')->build()->show()->execute(); /* $q1 = new Database_Query(); $q1 ->insert("names",'name',DB_IGNORE) ->select('name') ->frm('names') ->build() ->show() ->execute(); */ $db = new Database_Query(); $db->select('id as id', 'name as test')->frm('names')->build()->execute(); /* ->where( $db->_where('id = 1',DB_OR,'id = 4'), DB_AND, $db->_where('id = 2'), DB_AND, 'id = 3' ) */ // print_r($db->results()); $results = $db->results(); $this->v_test = $results; $this->extract['test'] = $results; }
/** * Метод позволяет дополнить запрос к БД в момент генерации данных спсика документов * или отдельного документа в виджете "Список ГД документов" и "Гибридный документ" * * @see DataSource_Hybrid_Agent::get_query_props() * * @param Database_Query $query * @return \Database_Query */ public function get_query_props(Database_Query $query, DataSource_Hybrid_Agent $agent) { $query->select(array($this->table_column_key(), $this->id)); }
public function get_query_props(Database_Query $query, DataSource_Hybrid_Agent $agent) { $sub_query = DB::select(DB::expr("GROUP_CONCAT(related_id SEPARATOR ',')"))->from('dshybrid_relations')->where('document_id', '=', DB::expr('d.id'))->where('field_id', '=', $this->id); $query->select(array($sub_query, $this->id)); }
/** * * @param Database_Query $db * @param array $clause * @return type */ public static function _conditions($db, array $clause) { foreach ($clause as $type => $params) { switch ($type) { case 'select': foreach ($params as $param) { $db->select($param); } break; case 'where': foreach ($params as $param) { $db->where($param[0], $param[1], $param[2]); } break; case 'or_where': foreach ($params as $param) { $db->or_where($param[0], $param[1], $param[2]); } break; case 'order_by': foreach ($params as $param) { $db->order_by($param[0], $param[1]); } break; case 'limit': $db->limit((int) $params); break; case 'offset': $db->offset((int) $params); break; } } return $db; }