thinkphp 在哪兒讀取的Conf/conf.php檔案裡的資料庫配置資訊

來源:互聯網
上載者:User
thinkphp 在哪裡讀取的Conf/conf.php檔案裡的資料庫配置資訊
研究thinkphp 架構幾天了,但始終找不到在執行個體化資料庫的時候,在哪裡擷取的資料庫配置資訊
'DB_TYPE'=>'mysql',
'DB_HOST'=>'localhost',
'DB_NAME'=>'examples',
'DB_USER'=>'root',
'DB_PWD'=>'123456',
'DB_PORT'=>'3306',
'DB_PREFIX'=>'think_',
然後,返回資料庫執行個體化對象

求高手解析

------解決方案--------------------
執行個體化 Think 類的時候 通過在 Think::buildApp 方法中調用 C 函數載入
並以靜態變數的形式保留在 C 函數中

------解決方案--------------------
$user=new Model("User");//"User"是資料庫表名
$user=M("User");這是thinkphp提供的一種簡便的寫法。
$list=$user->select();
var_dump($list);
配置是
config.inc.php檔案和
在控制器中
$arrr=array(
'dbms'=>'mysqli', //注意本書組中鍵名是規定的不能變動.
'username'=>'google',
'password'=>'hello',
'hostname'=>'127.0.0.1',
'database'=>'MYDBname',
);
$db=new Db($arrr);
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.