1、导入框架
define('APP_DEBUG', TRUE); //开启调试
require('../ThinkPHP/ThinkPHP.php');
测试是否应用成功
2、配置数据库
'DB_TYPE' => 'mysql', // 数据库类型
'DB_HOST' => 'localhost', // 服务器地址
'DB_NAME' => 'shopping', // 数据库名
'DB_USER' => 'root', // 用户名
'DB_PWD' => 'root', // 密码
'DB_PORT' => 8889, // 端口
'DB_PREFIX' => '', // 数据库表前缀
3、在/Lib/Action/下写类似IndexAction.class.php的网络接口
class UserAction extends Action{
public function index(){
echo "index";
}
public function show($userid){
// $user = M('user');
// $con['userid'] = $userid;
// $data = $user->where($con)->select();
// $this -> ajaxReturn($data,'JSON');
$user = new Model;
$data = $user->table('assess , user')
->where('assess.userid = user.userid')
->field('assess.assess,assess.userid,user.username')
->order('assess.userid')
->select();
$this -> ajaxReturn($data, 'JSON');
}
}
以上有一个多表查询,注释掉的是单表查询