模型分为表模型,视图模型
<?php namespace App\Blog\Model; use Lib\Bfw; use Lib\BoModel; use Lib\BoConfig; /** * @author Herry * 文章数据模型 */ class Model_Album extends BoModel { protected $_prikey = "id"; protected $_isview = false; private static $_instance; function __construct() { $this->_cBfwOnnarray= BoConfig::Config("Db", "localconfig"); parent::__construct(); } /** * 获取单例 * * @return Model */ public static function getInstance() { if (! (self::$_instance instanceof self)) { self::$_instance = new self(); } return self::$_instance; } /* * protected $_cBfwOnnarray= array( * "dbtype" => "DbMysql", * "dbconnstr" => "mysql:host=127.0.0.1;dbname=88art", * "dbport" => 3306, * "dbuser" => "root", * "dbpwd" => "" * ); */ } ?>视图模型为
<?php namespace App\Blog\Model; use Lib\Bfw; use Lib\BoModel; use Lib\BoConfig; /** * @author Herry * 文章数据模型 */ class Model_Album extends BoModel { protected $_prikey = "id"; protected $_isview = true; protected $_cpsql="select * from [[Article]] as a left join [[Tag]] as b on a.id=b.tid" ; private static $_instance; function __construct() { $this->_cBfwOnnarray= BoConfig::Config("Db", "localconfig"); parent::__construct(); } /** * 获取单例 * * @return Model */ public static function getInstance() { if (! (self::$_instance instanceof self)) { self::$_instance = new self(); } return self::$_instance; } /* * protected $_cBfwOnnarray= array( * "dbtype" => "DbMysql", * "dbconnstr" => "mysql:host=127.0.0.1;dbname=88art", * "dbport" => 3306, * "dbuser" => "root", * "dbpwd" => "" * ); */ } ?>
网友评论0