發(fā)表日期:2018-06 文章編輯:小燈 瀏覽次數(shù):2868
數(shù)據(jù)庫模型位于:phpcms/model/ 目錄下。
數(shù)據(jù)模型文件的命名規(guī)則建議為數(shù)據(jù)表名稱+'_model.class.php'
如果在我們的創(chuàng)建的模塊中我要使用一個(gè)數(shù)據(jù)庫“test”,首先需要建立一個(gè)數(shù)據(jù)庫模型文件,文件名稱為'test_model.class.php'
內(nèi)容如下:
<?phpdefined('IN_PHPCMS') or exit('No permission resources.');pc_base::load_sys_class('model', '', 0);class test_model extends model {public function __construct() {$this->db_config = pc_base::load_config('database');$this->db_setting = 'default';$this->table_name = 'test';parent::__construct();}}?>
$this->db = pc_base::load_model('test_model');
<?phpdefined('IN_PHPCMS') or exit('No permission resources.');class mytest {private $db;function __construct() {$this->db = pc_base::load_model('test_model');}public function init() {$result =$this->db->select();var_dump($result);}}?>
日期:2018-06 瀏覽次數(shù):3489
日期:2018-06 瀏覽次數(shù):3305
日期:2018-06 瀏覽次數(shù):3344
日期:2018-06 瀏覽次數(shù):3329
日期:2018-06 瀏覽次數(shù):3147
日期:2018-06 瀏覽次數(shù):3383
日期:2018-06 瀏覽次數(shù):3203
日期:2018-06 瀏覽次數(shù):3309
日期:2018-06 瀏覽次數(shù):3478
日期:2018-06 瀏覽次數(shù):3211
日期:2018-06 瀏覽次數(shù):2959
日期:2018-06 瀏覽次數(shù):3001
日期:2018-06 瀏覽次數(shù):3036
日期:2018-06 瀏覽次數(shù):2691
日期:2018-06 瀏覽次數(shù):2929
日期:2018-06 瀏覽次數(shù):2770
日期:2018-06 瀏覽次數(shù):2683
日期:2018-06 瀏覽次數(shù):2868
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.