gyro/core/lib/interfaces/idbquery.cls.php
Go to the documentation of this file.00001 <?php 00002 require_once dirname(__FILE__) . '/idbsqlbuilder.cls.php'; 00003 require_once dirname(__FILE__) . '/ipolicyholder.cls.php'; 00004 require_once dirname(__FILE__) . '/idbwhereholder.cls.php'; 00005 00006 /** 00007 * Represents a DB query 00008 * 00009 * @author Gerd Riesselmann 00010 * @ingroup Interfaces 00011 */ 00012 interface IDBQuery extends IDBSqlBuilder, IPolicyHolder, IDBWhereHolder { 00013 /** 00014 * Used for clearing fields 00015 */ 00016 const CLEAR = null; 00017 /** 00018 * Default policy 00019 */ 00020 const NORMAL = 0; 00021 00022 /** 00023 * Returns table 00024 * 00025 * @return IDBTable 00026 */ 00027 public function get_table(); 00028 00029 /** 00030 * Set the fields this query affects 00031 * 00032 * Dependent on the query time, the array passed can be of different forms 00033 * 00034 * UPDATE and INSERT: Associative array with field name as key and field value as value 00035 * 00036 * $query = new DBQuery($some_table); 00037 * $query->set_fields(array('name' => 'Johnny')); 00038 * $query->add_where('id', '=', 3); 00039 * $sql = $query->build_update_sql(); // returns UPDATE some_table SET name = 'Johnny' WHERE id = 3 00040 * 00041 * SELECT: Either array of field names or associative array with field name as key and field alias as value. 00042 * Both can be combined. 00043 * 00044 * $query = new DBQuery($some_table); 00045 * $query->set_fields(array('count(name)' => 'c', 'phone')); 00046 * $sql = $query->build_select_sql(); // returns SELECT count(name) AS c, phone FROM some_table 00047 * 00048 * If invoked with DBQuery::CLEAR, the fields will get cleared 00049 * 00050 * @param array $arr_fields 00051 * @return void 00052 */ 00053 public function set_fields($arr_fields); 00054 00055 /** 00056 * Add a field 00057 * 00058 * @param mixed $field 00059 */ 00060 public function add_field($field); 00061 00062 /** 00063 * Return fields 00064 * 00065 * @return array 00066 */ 00067 public function get_fields(); 00068 }