00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010 class DataObjectBase implements IDataObject, IActionSource {
00011
00012
00013
00014
00015
00016 protected $table = null;
00017
00018
00019
00020
00021
00022 protected $resultset = null;
00023
00024
00025
00026
00027
00028 protected $where = null;
00029
00030
00031
00032
00033
00034 protected $limit = array(0,0);
00035 protected $order_by = array();
00036
00037
00038
00039
00040
00041 protected $joins = array();
00042 protected $queryhooks = array();
00043
00044
00045 public function __construct() {
00046 $this->table = $this->init_table_object();
00047 $this->where = new DBWhereGroup($this);
00048 }
00049
00050
00051
00052
00053
00054
00055 protected function init_table_object() {
00056
00057 $name = strtolower(get_class($this));
00058 if (substr($name, 0, 3) == 'dao') {
00059 $name = substr($name, 3);
00060 }
00061 $ret = DBTableRepository::get($name);
00062 if (empty($ret)) {
00063 $ret = $this->create_table_object();
00064 DBTableRepository::register($ret, $name);
00065 }
00066 return $ret;
00067 }
00068
00069 public function __destruct() {
00070 if ($this->resultset) {
00071 $this->resultset->close();
00072 }
00073 unset($this->resultset);
00074 unset($this->table);
00075 unset($this->where);
00076 }
00077
00078 public function __clone() {
00079 $this->resultset = null;
00080 $this->where = new DBWhereGroup($this);
00081 $this->limit = array(0,0);
00082 $this->order_by = array();
00083 }
00084
00085 public function __sleep() {
00086 $properties = get_object_vars($this);
00087 foreach($this->get_properties_to_exclude_for_sleep() as $prop) {
00088 unset($properties[$prop]);
00089 }
00090 return array_keys($properties);
00091 }
00092
00093 protected function get_properties_to_exclude_for_sleep() {
00094 return array('table', 'where', 'limit', 'order_by', 'resultset', 'joins');
00095 }
00096
00097 public function __wakeup() {
00098 $this->table = $this->create_table_object();
00099 $this->where = new DBWhereGroup($this);
00100 }
00101
00102 public function __toString() {
00103 return $this->to_string();
00104 }
00105
00106 public function to_string() {
00107 $ret = '';
00108 $fields = array();
00109 foreach($this->get_table_keys() as $key_field) {
00110
00111 $col_name = $key_field->get_field_name();
00112 $fields[$col_name] = $this->$col_name;
00113 }
00114
00115 $ret .= $this->get_table_name();
00116 if (count($fields)) {
00117 $ret .= '[' . Arr::implode('|', $fields, '=') . ']';
00118 }
00119
00120 return $ret;
00121 }
00122
00123
00124
00125
00126
00127
00128
00129
00130 public function set_default_values() {
00131 foreach($this->get_table_fields() as $column => $field) {
00132 $this->$column = $field->get_field_default();
00133 }
00134 }
00135
00136
00137
00138
00139
00140
00141
00142
00143 public function save() {
00144 $bInsert = true;
00145 foreach($this->get_table_keys() as $column => $field) {
00146 $bInsert = $bInsert && empty($this->$column);
00147 }
00148 if ($bInsert) {
00149 return $this->insert();
00150 }
00151 else {
00152 return $this->replace();
00153 }
00154 }
00155
00156
00157
00158
00159
00160
00161 public function insert() {
00162 $query = $this->create_insert_query();
00163 $connection = $query->get_table()->get_table_driver();
00164 $ret = DB::execute($query->get_sql(), $connection);
00165
00166 $this->set_last_insert_id($connection);
00167 return $ret;
00168 }
00169
00170
00171
00172
00173 protected function set_last_insert_id($connection) {
00174
00175 $table_keys = $this->get_table_keys();
00176 $id_field = array_shift($table_keys);
00177 if ($id_field && $id_field instanceof DBFieldInt && $id_field->has_policy(DBFieldInt::AUTOINCREMENT)) {
00178 $fieldname = $id_field->get_field_name();
00179 if (empty($this->$fieldname)) {
00180 $this->$fieldname = DB::last_insert_id($connection);
00181 }
00182 }
00183 }
00184
00185
00186
00187
00188 protected function get_field_values($only_set = true) {
00189 $b_all = !$only_set;
00190 $ret = array();
00191 foreach($this->get_table_fields() as $column => $field) {
00192 if ($b_all || isset($this->$column)) {
00193 $v = $this->$column;
00194 if ($v instanceof DBNull) {
00195 $v = NULL;
00196 }
00197 $ret[$column] = $v;
00198 }
00199 }
00200 return $ret;
00201 }
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211 public function replace() {
00212 $arr_keys = $this->get_table_keys();
00213 $b_keys_complete = true;
00214 foreach($arr_keys as $key_column => $field) {
00215
00216 if (empty($this->$key_column)) {
00217 $b_keys_complete = false;
00218 break;
00219 }
00220 }
00221
00222
00223 if (!$b_keys_complete) {
00224 return new Status(tr(
00225 'Replace cannot be called with a key beeing empty',
00226 'core'
00227 ));
00228 }
00229
00230 $ret = new Status();
00231 $driver = $this->get_table_driver();
00232 if ($driver->has_feature(IDBDriver::FEATURE_REPLACE)) {
00233 $query = $this->create_replace_query();
00234 $ret->merge(DB::execute($query, $driver));
00235 }
00236 else {
00237 $ret->merge($this->replace_manual());
00238 }
00239 return $ret;
00240 }
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250 protected function replace_manual() {
00251 $arr_keys = $this->get_table_keys();
00252
00253
00254 $query = new DBQuerySelect($this, DBQuerySelect::FOR_UPDATE);
00255 foreach($arr_keys as $key_column => $field) {
00256 $query->add_where($key_column, '=', $this->$key_column);
00257 }
00258 $result = DB::query($query->get_sql(), $query->get_table()->get_table_driver());
00259
00260 $ret = $result->get_status();
00261 if ($ret->is_ok()) {
00262 if ($result->get_row_count() > 0) {
00263 $ret->merge($this->update());
00264 }
00265 else {
00266 $ret->merge($this->insert());
00267 }
00268 }
00269 return $ret;
00270 }
00271
00272
00273
00274
00275
00276
00277
00278 public function update($policy = self::NORMAL) {
00279 $query = $this->create_update_query($policy);
00280 return DB::execute($query->get_sql(), $query->get_table()->get_table_driver());
00281 }
00282
00283
00284
00285
00286
00287
00288
00289
00290 public function delete($policy = self::NORMAL) {
00291 $query = $this->create_delete_query($policy);
00292 return DB::execute($query->get_sql(), $query->get_table()->get_table_driver());
00293 }
00294
00295
00296
00297
00298
00299
00300 public function read_from_array($values) {
00301 foreach($this->get_table_fields() as $prop => $field) {
00302 $value = $field->read_from_array($values);
00303 if (!is_null($value)) {
00304 $this->$prop = $value;
00305 }
00306 }
00307 }
00308
00309
00310
00311
00312
00313
00314
00315 public function unset_internals($arr_properties) {
00316 $ret = array();
00317
00318 foreach($arr_properties as $field => $value) {
00319 $dbfield = $this->get_table_field($field);
00320 if ($dbfield && $dbfield->has_policy(DBField::INTERNAL)) {
00321 continue;
00322 }
00323 $ret[$field] = $value;
00324 }
00325
00326 foreach($this->get_table_keys() as $field => $tmp) {
00327 unset($ret[$field]);
00328 }
00329 return $ret;
00330 }
00331
00332
00333
00334
00335
00336
00337 public function validate() {
00338 $ret = new Status();
00339 $fields = $this->get_field_values(false);
00340 foreach($this->get_table_fields() as $column => $field) {
00341 $val = Arr::get_item($fields, $column, null);
00342 $ret->merge($field->validate($val));
00343 }
00344 if ($ret->is_ok()) {
00345
00346 foreach($this->get_table_relations() as $relation) {
00347
00348 $arr_val = array();
00349 foreach($relation->get_fields() as $column => $fieldrelation) {
00350
00351 $arr_val[$column] = Arr::get_item($fields, $column, null);
00352 }
00353 $ret->merge($relation->validate($arr_val));
00354 }
00355 foreach($this->get_table_constraints() as $constraint) {
00356
00357 $arr_val = array();
00358 $arr_keys = array();
00359 foreach($constraint->get_fields() as $column) {
00360 $arr_val[$column] = Arr::get_item($fields, $column, null);
00361 }
00362 foreach($this->get_table_keys() as $column => $field_object) {
00363 $arr_keys[$column] = Arr::get_item($fields, $column, null);
00364 }
00365 $ret->merge($constraint->validate($arr_val, $arr_keys));
00366 }
00367 }
00368 return $ret;
00369 }
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380 public function get($column_or_value, $value = null) {
00381 if (empty($value)) {
00382 $value = $column_or_value;
00383 $keys = array_keys($this->get_table_keys());
00384 $column_or_value = Arr::get_item($keys, 0, false);
00385 }
00386 if (empty($column_or_value)) {
00387 throw new Exception(tr('No column set for get', 'core'));
00388 }
00389
00390 $query = new DBQuerySelect($this);
00391 $query->add_where($column_or_value, '=', $value);
00392 $query->set_limit(1);
00393
00394 $this->resultset = DB::query($query->get_sql(), $query->get_table()->get_table_driver());
00395 return $this->fetch();
00396 }
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410 public function find($policy = self::NORMAL) {
00411 $query = $this->create_select_query();
00412 return $this->query($query->get_sql(), $policy);
00413 }
00414
00415
00416
00417
00418
00419
00420 public function find_array() {
00421 $this->find();
00422 return $this->fetch_array();
00423 }
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442 public function fetch() {
00443 $ret = false;
00444 if (!empty($this->resultset)) {
00445 $arr_data = $this->resultset->fetch();
00446 if ($arr_data) {
00447 foreach($arr_data as $prop => $value) {
00448 $field = $this->get_table_field($prop);
00449 if ($field) {
00450 $value = $field->convert_result($value);
00451 }
00452 $this->$prop = $value;
00453 }
00454 $ret = true;
00455 }
00456 else {
00457 $this->resultset = null;
00458 }
00459 }
00460 return $ret;
00461 }
00462
00463
00464
00465
00466
00467
00468 public function fetch_array() {
00469 $arrRet = array();
00470 while ($this->fetch()) {
00471 $arrRet[] = clone($this);
00472 }
00473
00474 return $arrRet;
00475 }
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497 public function add_where($column, $operator = null, $value = null, $mode = 'AND') {
00498 $this->where->add_where($column, $operator, $value, $mode);
00499 }
00500
00501
00502
00503
00504 public function add_where_object(IDBWhere $where) {
00505 $this->where->add_where_object($where);
00506 }
00507
00508
00509
00510
00511
00512
00513 public function get_wheres() {
00514 return $this->where;
00515 }
00516
00517
00518
00519
00520
00521
00522
00523
00524 public function join(IDBTable $other, $conditions = array(), $type = DBQueryJoined::INNER) {
00525 $this->joins[] = array(
00526 'table' => $other,
00527 'conditions' => Arr::force($conditions, false),
00528 'type' => $type
00529 );
00530 }
00531
00532
00533
00534
00535
00536
00537
00538 public function quote($val) {
00539 return DB::quote($val, $this->get_table_driver());
00540 }
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551 public function is_same_as($other) {
00552 $ret = ($other instanceof IDataObject);
00553 $ret = $ret && ($this->get_table_name() === $other->get_table_name());
00554 if ($ret) {
00555 foreach($this->get_table_keys() as $name => $field_object) {
00556 $ret = $ret && ($this->$name === $other->$name);
00557 }
00558 }
00559 return $ret;
00560 }
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571 public function equals($other) {
00572 $ret = ($other instanceof IDataObject);
00573 $ret = $ret && ($this->get_table_name() === $other->get_table_name());
00574 if ($ret) {
00575 foreach($this->get_table_fields() as $name => $field_object) {
00576 $ret = $ret && ($this->$name === $other->$name);
00577 }
00578 }
00579 return $ret;
00580 }
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591 public function count() {
00592 $query = $this->create_count_query();
00593 $result = DB::query($query);
00594 $ret = false;
00595 if ($result->get_status()->is_ok()) {
00596 $arr = $result->fetch();
00597 $ret = Arr::get_item($arr, 'c', 0);
00598 }
00599 return $ret;
00600 }
00601
00602
00603
00604
00605 public function limit($start = 0, $number_of_items = 0) {
00606 $this->limit[0] = $start;
00607 $this->limit[1] = $number_of_items;
00608 }
00609
00610
00611
00612
00613
00614
00615 public function execute() {
00616 return $this->find_array();
00617 }
00618
00619
00620
00621
00622 public function get_sortable_columns() {
00623 return array();
00624 }
00625
00626
00627
00628
00629 public function get_sort_default_column() {
00630 return '';
00631 }
00632
00633
00634
00635
00636
00637
00638
00639 public function sort($column, $order = self::ASC) {
00640 if ($column == self::CLEAR) {
00641 $this->order_by = array();
00642 }
00643 else {
00644 $this->order_by[] = array($column => $order);
00645 }
00646 }
00647
00648
00649
00650
00651 public function get_filters() {
00652 return false;
00653 }
00654
00655
00656
00657
00658
00659
00660 public function apply_modifier($modifier) {
00661 if ($modifier) {
00662 $modifier->apply($this);
00663 }
00664 }
00665
00666
00667
00668
00669 public function set_table_alias($alias) {
00670 $this->table = new DBTableAlias($this->table, $alias);
00671 }
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682 public function get_table_name() {
00683 return $this->table->get_table_name();
00684 }
00685
00686
00687
00688
00689
00690
00691 public function get_table_alias() {
00692 return $this->table->get_table_alias();
00693 }
00694
00695
00696
00697
00698
00699
00700 public function get_table_name_escaped() {
00701 return $this->table->get_table_name_escaped();
00702 }
00703
00704
00705
00706
00707
00708
00709 public function get_table_alias_escaped() {
00710 return $this->table->get_table_alias_escaped();
00711 }
00712
00713
00714
00715
00716
00717
00718 public function get_table_fields() {
00719 return $this->table->get_table_fields();
00720 }
00721
00722
00723
00724
00725
00726
00727
00728 public function get_table_field($column) {
00729 return $this->table->get_table_field($column);
00730 }
00731
00732
00733
00734
00735
00736
00737 public function get_table_keys() {
00738 return $this->table->get_table_keys();
00739 }
00740
00741
00742
00743
00744
00745
00746 public function get_table_relations() {
00747 return $this->table->get_table_relations();
00748 }
00749
00750
00751
00752
00753
00754
00755
00756 public function get_matching_relations(IDBTable $other) {
00757 return $this->table->get_matching_relations($other);
00758 }
00759
00760
00761
00762
00763
00764
00765 public function get_table_constraints() {
00766 return $this->table->get_table_constraints();
00767 }
00768
00769
00770
00771
00772
00773
00774 public function get_table_driver() {
00775 return $this->table->get_table_driver();
00776 }
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804 public function get_actions($user, $context = 'view', $params = false) {
00805 $actions = $this->get_actions_for_context($context, $user, $params);
00806
00807 $actions_event_result = array();
00808 $actions_event_params = array(
00809 'source' => $this,
00810 'source_name' => $this->get_action_source_name(),
00811 'context' => $context,
00812 'params' => $params,
00813 'instance_actions' => $actions
00814 );
00815 EventSource::Instance()->invoke_event('get_actions', $actions_event_params, $actions_event_result);
00816 $actions = array_merge($actions, $actions_event_result);
00817
00818
00819 unset($actions[$context]);
00820 $ret = array();
00821 foreach($actions as $name => $iaction_or_description) {
00822 if ($iaction_or_description instanceof IAction) {
00823 $ret[] = $iaction_or_description;
00824 }
00825 else {
00826 $description = $iaction_or_description;
00827 if (empty($description)) {
00828 continue;
00829 }
00830 $actionsource = $this;
00831 $action = $name;
00832 if (strpos($name, '::') !== false) {
00833 $tmp = explode('::', $name);
00834 $actionsource = array_shift($tmp);
00835 $action = implode('_', $tmp);
00836 $name = str_replace('::', '_', $name);
00837 }
00838
00839 $cmd = $this->find_action_command($name);
00840 if ($cmd) {
00841 if ($cmd->can_execute($user)) {
00842 $ret[] = $cmd;
00843 }
00844 }
00845 else {
00846 if (AccessControl::is_allowed($action, $actionsource, $params, $user)) {
00847 $ret[] = new ActionBase($this, $name, $description);
00848 }
00849 }
00850 }
00851 }
00852
00853 return $ret;
00854 }
00855
00856
00857
00858
00859
00860
00861 public function get_action_source_name() {
00862 return $this->get_table_name();
00863 }
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877 protected function get_actions_for_context($context, $user, $params) {
00878 return array();
00879 }
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889 protected function find_action_command($name) {
00890 $params = false;
00891 $pos_params = strpos($name, '[');
00892 if ($pos_params !== false) {
00893 $params = trim(substr($name, $pos_params + 1), ']');
00894 $name = substr($name, 0, $pos_params);
00895 $params = explode(',', $params);
00896 }
00897 $ret = CommandsFactory::create_command($this, $name, $params);
00898 return $ret;
00899 }
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911 public function create_select_query($policy = self::NORMAL) {
00912 $query = new DBQuerySelect($this, DBQuerySelect::NONE);
00913 $this->configure_select_query($query, $policy);
00914 $this->execute_query_hooks($query);
00915 return $query;
00916 }
00917
00918
00919
00920
00921
00922
00923
00924 protected function configure_select_query($query, $policy) {
00925 $query->add_where_object($this->where);
00926
00927 if (!Common::flag_is_set($policy, self::WHERE_ONLY)) {
00928 $recent_values = $this->get_field_values();
00929 foreach($recent_values as $column => $value) {
00930 if (is_null($value)) {
00931 $query->add_where($column, DBWhere::OP_IS_NULL);
00932 }
00933 else {
00934 $query->add_where($column, '=', $value);
00935 }
00936 }
00937 }
00938
00939 $query->set_limit($this->limit[0], $this->limit[1]);
00940 foreach($this->order_by as $order_by) {
00941 $query->add_order(key($order_by), current($order_by));
00942 }
00943
00944 $use_distinct = false;
00945 foreach($this->joins as $join) {
00946 $joined_table = $join['table'];
00947 $conditions = $join['conditions'];
00948 $joined_query = $query->add_join($joined_table);
00949 $joined_query->set_join_type(Arr::get_item($join, 'type', DBQueryJoined::INNER));
00950 if (count($conditions) > 0) {
00951 $joined_query->set_policy(DBQuery::NONE);
00952 foreach($conditions as $cond) {
00953 $joined_query->add_join_condition_object($cond);
00954 }
00955 }
00956 $use_distinct = $use_distinct || ($joined_query->get_relation_type() != DBRelation::ONE_TO_ONE);
00957 if ($joined_table instanceof DataObjectBase) {
00958 $joined_table->configure_select_query($joined_query, self::NORMAL);
00959 }
00960 }
00961 if ($use_distinct) {
00962 $query->set_policy($query->get_policy() | DBQuerySelect::DISTINCT);
00963 }
00964 }
00965
00966
00967
00968
00969
00970
00971 public function create_insert_query() {
00972 $query = new DBQueryInsert($this);
00973 $this->configure_insert_query($query);
00974 $this->execute_query_hooks($query);
00975 return $query;
00976 }
00977
00978
00979
00980
00981
00982
00983 protected function configure_insert_query($query) {
00984 $fields = $this->get_field_values();
00985
00986
00987
00988
00989 $query->set_fields($fields);
00990 }
00991
00992
00993
00994
00995
00996
00997
00998 public function create_update_query($policy = self::NORMAL) {
00999 $query = new DBQueryUpdate($this);
01000 $this->configure_update_query($query, $policy);
01001 $this->execute_query_hooks($query);
01002 return $query;
01003 }
01004
01005
01006
01007
01008
01009
01010
01011 protected function configure_update_query($query, $policy) {
01012 $fields = $this->get_field_values();
01013
01014 $where = new DBWhereGroup($query->get_table());
01015 $where->add_where_object($this->where);
01016
01017 if (!Common::flag_is_set($policy, self::WHERE_ONLY)) {
01018 foreach($this->get_table_keys() as $column => $field) {
01019 if (!isset($fields[$column])) {
01020
01021 throw new Exception(tr('Trying to UPDATE without all keys set. If intended, use WHERE_ONLY policy', 'core'));
01022 }
01023 unset($fields[$column]);
01024 $where->add_where($column, '=', $this->$column);
01025 }
01026 }
01027
01028 $query->add_where_object($where);
01029 $query->set_fields($fields);
01030 }
01031
01032
01033
01034
01035
01036
01037 public function create_replace_query() {
01038 $query = new DBQueryReplace($this);
01039 $this->configure_replace_query($query);
01040 $this->execute_query_hooks($query);
01041 return $query;
01042 }
01043
01044
01045
01046
01047
01048
01049 protected function configure_replace_query($query) {
01050 $fields = $this->get_field_values();
01051 $query->set_fields($fields);
01052 }
01053
01054
01055
01056
01057
01058
01059
01060 public function create_delete_query($policy = self::NORMAL) {
01061 $query = new DBQueryDelete($this);
01062 $this->configure_delete_query($query, $policy);
01063 $this->execute_query_hooks($query);
01064 return $query;
01065 }
01066
01067
01068
01069
01070
01071
01072
01073 protected function configure_delete_query($query, $policy) {
01074 $where = new DBWhereGroup($query->get_table());
01075 $where->add_where_object($this->where);
01076
01077 if (!Common::flag_is_set($policy, self::WHERE_ONLY)) {
01078 $fields = $this->get_field_values();
01079 foreach($this->get_table_keys() as $column => $field) {
01080 if (!isset($fields[$column])) {
01081
01082 throw new Exception(tr('Trying to DELETE without all keys set. If intended, use WHERE_ONLY policy', 'core'));
01083 }
01084 $where->add_where($column, '=', $this->$column);
01085 }
01086 }
01087
01088 $query->add_where_object($where);
01089
01090 $query->set_limit($this->limit[0], $this->limit[1]);
01091 foreach($this->order_by as $order_by) {
01092 $query->add_order(key($order_by), current($order_by));
01093 }
01094 }
01095
01096
01097
01098
01099
01100
01101
01102 public function create_count_query($policy = self::NORMAL) {
01103 $query = new DBQueryCount($this);
01104 $this->configure_count_query($query, self::NORMAL);
01105 $this->execute_query_hooks($query);
01106 return $query;
01107 }
01108
01109
01110
01111
01112
01113
01114
01115 protected function configure_count_query($query, $policy) {
01116 $this->configure_select_query($query, $policy);
01117 }
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130 public function query($query, $policy = self::NORMAL, $connection = false) {
01131 $connection = ($connection) ? $connection : $this->get_table_driver();
01132 $this->resultset = DB::query($query, $connection);
01133 $ret = $this->resultset->get_row_count();
01134
01135 if (Common::flag_is_set($policy, self::AUTOFETCH)) {
01136 $this->fetch();
01137 }
01138
01139 return $ret;
01140 }
01141
01142
01143
01144
01145
01146
01147 public function register_query_hook(IDataObjectQueryHook $hook) {
01148 $this->queryhooks[] = $hook;
01149 }
01150
01151
01152
01153
01154
01155
01156
01157
01158 protected function create_table_object() {
01159 return new DBTable('test');
01160 }
01161
01162 protected function reset() {
01163 $this->resultset = null;
01164 }
01165
01166
01167
01168
01169
01170
01171 protected function execute_query_hooks($query) {
01172 foreach($this->queryhooks as $hook) {
01173 $hook->configure_query($query);
01174 }
01175 }
01176 }