get_model.class.php 872 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. defined('IN_PHPCMS') or exit('No permission resources.');
  3. pc_base::load_sys_class('model', '', 0);
  4. class get_model extends model {
  5. public $db_config, $db_setting;
  6. public function __construct($db_config = array(), $db_setting = '') {
  7. if (!$db_config) {
  8. $this->db_config = pc_base::load_config('database');
  9. } else {
  10. $this->db_config = $db_config;
  11. }
  12. if (!$db_setting) {
  13. $this->db_setting = 'default';
  14. } else {
  15. $this->db_setting = $db_setting;
  16. }
  17. parent::__construct();
  18. if ($db_setting && $db_config[$db_setting]['db_tablepre']) {
  19. $this->db_tablepre = $db_config[$db_setting]['db_tablepre'];
  20. }
  21. }
  22. public function sql_query($sql) {
  23. if (!empty($this->db_tablepre)) $sql = str_replace('phpcms_', $this->db_tablepre, $sql);
  24. return parent::query($sql);
  25. }
  26. public function fetch_next() {
  27. return $this->db->fetch_next();
  28. }
  29. }
  30. ?>