發(fā)表日期:2018-06 文章編輯:小燈 瀏覽次數(shù):2820
數(shù)據(jù)庫(kù)模型位于:phpcms/model/ 目錄下。
數(shù)據(jù)模型文件的命名規(guī)則建議為數(shù)據(jù)表名稱+'_model.class.php'
如果在我們的創(chuàng)建的模塊中我要使用一個(gè)數(shù)據(jù)庫(kù)“test”,首先需要建立一個(gè)數(shù)據(jù)庫(kù)模型文件,文件名稱為'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ù):3429
日期:2018-06 瀏覽次數(shù):3253
日期:2018-06 瀏覽次數(shù):3298
日期:2018-06 瀏覽次數(shù):3275
日期:2018-06 瀏覽次數(shù):3083
日期:2018-06 瀏覽次數(shù):3295
日期:2018-06 瀏覽次數(shù):3121
日期:2018-06 瀏覽次數(shù):3259
日期:2018-06 瀏覽次數(shù):3410
日期:2018-06 瀏覽次數(shù):3153
日期:2018-06 瀏覽次數(shù):2903
日期:2018-06 瀏覽次數(shù):2946
日期:2018-06 瀏覽次數(shù):2949
日期:2018-06 瀏覽次數(shù):2626
日期:2018-06 瀏覽次數(shù):2876
日期:2018-06 瀏覽次數(shù):2719
日期:2018-06 瀏覽次數(shù):2631
日期:2018-06 瀏覽次數(shù):2819
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.