<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                模型初始化 initialize( ) 1. 作用:創建模型對象之前做的預處理工作。 在ThinkPHP5中,創建數據模型是一個非常容易的過程,整個過程是透明的。 2. 實例演示:創建模型對象前,初始化部分模型類屬性 模型對象創建時,除了模型名$name和所繼承的類$class(命名空間表示)之外,其它所有的模型屬性都是空的或只有默認值。隨著以后的操作,這些屬性會根據操作要求自動完成初始化。 第一步:在上節課創建的模型類Staff.php里,添加初始化方法 ~~~ <?php namespace app\index\model; //導入模型類(首字母大寫) use think\Model; class Staff extends Model { //在子類重寫父類的初始化方法initialize() protected function initialize(){ //繼承父類中的initialize() parent::initialize(); //初始化數據表名稱,通常自動獲取不需設置 $this->table = 'tp5_staff'; ~~~ 獲取數據表字段信息 ~~~ //獲取數據表字段信息 $this->field = $this->db()->getTableInfo('', 'fields'); ~~~ 輸出數據庫表字段 ~~~ array(6) { [0] => string(2) "id" [1] => string(4) "name" [2] => string(3) "sex" [3] => string(6) "salary" [4] => string(4) "dept" [5] => string(8) "hiredate" } ~~~ 獲取數據表字段類型 ~~~ //初始化數據表字段類型 $this->type = $this->db()->getTableInfo('', 'type'); ~~~ 輸出數據表字段類型 ~~~ array(6) { ["id"] => string(15) "int(4) unsigned" ["name"] => string(11) "varchar(30)" ["sex"] => string(19) "tinyint(2) unsigned" ["salary"] => string(11) "float(10,2)" ["dept"] => string(11) "varchar(20)" ["hiredate"] => string(4) "date" } ~~~ 獲取數據表主鍵 ~~~ //獲取數據表主鍵 $this->pk = $this->db()->getTableInfo('', 'pk'); ~~~ 輸出數據表主鍵 ~~~ string(2) "id" ~~~ 初始化之后得到的數據模型對象 ~~~ object(app\index\model\Staff)#5 (32) { ["connection":protected] => array(0) { } ["parent":protected] => NULL ["query":protected] => NULL ["name":protected] => string(5) "Staff" ["table":protected] => string(9) "tp5_staff" ["class":protected] => string(21) "app\index\model\Staff" ["error":protected] => NULL ["validate":protected] => NULL ["pk":protected] => string(2) "id" ["field":protected] => array(6) { [0] => string(2) "id" [1] => string(4) "name" [2] => string(3) "sex" [3] => string(6) "salary" [4] => string(4) "dept" [5] => string(8) "hiredate" } ["readonly":protected] => array(0) { } ["visible":protected] => array(0) { } ["hidden":protected] => array(0) { } ["append":protected] => array(0) { } ["data":protected] => array(0) { } ["origin":protected] => array(0) { } ["relation":protected] => array(0) { } ["auto":protected] => array(0) { } ["insert":protected] => array(0) { } ["update":protected] => array(0) { } ["autoWriteTimestamp":protected] => bool(false) ["createTime":protected] => string(11) "create_time" ["updateTime":protected] => string(11) "update_time" ["dateFormat":protected] => string(11) "Y-m-d H:i:s" ["type":protected] => array(6) { ["id"] => string(15) "int(4) unsigned" ["name"] => string(11) "varchar(30)" ["sex"] => string(19) "tinyint(2) unsigned" ["salary"] => string(11) "float(10,2)" ["dept"] => string(11) "varchar(20)" ["hiredate"] => string(4) "date" } ["isUpdate":protected] => bool(false) ["updateWhere":protected] => NULL ["failException":protected] => bool(false) ["useGlobalScope":protected] => bool(true) ["batchValidate":protected] => bool(false) ["resultSetType":protected] => string(5) "array" ["relationWrite":protected] => NULL } ~~~ * * * * * [《ThinkPHP5模型實例詳解》](http://www.hmoore.net/ldkt/tp5_model)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看