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

相关文章
相关标签/搜索