1、下載Thinkphp3.2.3架構
2、解壓放到WWW檔案夾
3、在Application->Home->Controller下資料控制器IndexController.class.php 代碼
<?phpnamespace Home\Controller;use Think\Controller;class IndexController extends Controller { public function index(){ $Data =M('notice'); $result =$Data->find(1); $this->assign('result',$result); $this->show(); }}
4、Application->Home->View下建立檔案夾index,建立index.html代碼
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title></head><body>{$result.id}</body></html> 5、Application->Home->Conf->Config.php配置模組檔案訪問資料庫
<?phpreturn array( //'配置項'=>'配置值' 'DB_TYPE' => 'mysql', // 資料庫類型 'DB_HOST' => 'localhost', // 伺服器位址 'DB_NAME' => 'tuiguang', // 資料庫名 'DB_USER' => 'root', // 使用者名稱 'DB_PWD' => '', // 密碼 'DB_PORT' => '3306', // 連接埠 'DB_PREFIX' => 'tuiguang_', // 資料庫表首碼 'DB_PARAMS' => array(), // 資料庫連接參數 'DB_DEBUG' => TRUE, // 資料庫偵錯模式 開啟後可以記錄SQL日誌 'DB_FIELDS_CACHE' => true, // 啟用欄位緩衝 'DB_CHARSET' => 'utf8', // 資料庫編碼預設採用utf8 'DB_DEPLOY_TYPE' => 0, // 資料庫部署方式:0 集中式(單一伺服器),1 分布式(主從伺服器) 'DB_RW_SEPARATE' => false, // 資料庫讀寫是否分離 主從式有效 'DB_MASTER_NUM' => 1, // 讀寫分離後 主伺服器數量 'DB_SLAVE_NO' => '', // 指定從伺服器序號);
6、phpMyAdmin建立個資料庫tuiguang,並且建立個表命名為tuiguang_notice,新增欄位id,插入值1
7、瀏覽器輸入localhost可以顯示1