tp5.1连接数据库后检测表输出测试数据

配置好全局
config\database.php

tp5.1连接数据库后检测表输出测试数据
检查数据表
tp5.1连接数据库后检测表输出测试数据
tp5.1连接数据库后检测表输出测试数据
入口文件index.php/控制器/方法
index.php/index/Data/conn

<?php namespace app\index\controller; use think\Db; class Data { public function conn() { return Db::table('tp_auth_group') ->where('id',2) ->value('title'); } } ?>

浏览器表输出测试数据
管理员

tp5.1连接数据库后检测表输出测试数据
此表那个字段都输出数据失败,不明白,
public根目录下/indexdata.php
/indexdata.php
直接调用数据表测试

<?php //$con = mysql_connect("localhost","root","password"); $con = mysql_connect("localhost","root","root"); $select_db = mysql_select_db('tp51smcms'); if (!$select_db) { die("could not connect to the db:\n" . mysql_error()); } //查询代码 //$sql = "select * from db_table"; $sql = "select * from tp_member"; $res = mysql_query($sql); if (!$res) { die("could get the res:\n" . mysql_error()); } while ($row = mysql_fetch_assoc($res)) { print_r($row); } //查询代码 //关闭数据库连接 mysql_close($con); ?>

浏览器输出
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in
Array ( [id] => 1 [name] => admin [password] => 45c60afb82a08f60cfa6691a07b49487 [nickname] => 超级管理员 [email] => [email protected] [url] => [avatar] => /static/admin/images/default_avatar.png [gender] => secret [birthday] => [signature] => [last_login_ip] => 0 [last_login_time] => 0 [activation_key] => [status] => 1 [member_id] => 0 [group_id] => 0 [mobile] => [create_time] => 1552897039 [update_time] => 1552897039 [delete_time] => 0 ) ?>