tp5 學習 1

index.phpphp

 

<?php
namespace app\index\controller;
use think\ Controller;
use think\ Db;
class Index extends Controller
{
public function index( $name)
{
echo "hello ". $name;
}
public function hello( $name){
$data= Db:: name( 'think_data')-> find();
$this-> assign( 'result', $data);
return $this-> fetch();
}
}

 

hello.htmlhtml

 

< body >
{$result.id}--{$result.data}
</ body >

 

數據庫thinkphp

CREATE TABLE IF NOT EXISTS `think_data`(
`id` int(8) unsigned NOT NULL AUTO_INCREMENT,
`data` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
INSERT INTO `think_data`(`id`,`data`) VALUES
(1,'thinkphp'),
(2,'php'),數據庫

(3,'framework');app

 

數據庫配置 在 application/database.php中配置ide

相關文章
相關標籤/搜索