- 先在Navicat建好数据库,然后在项目文件夹model下建PHP.web文件,然后引入include_once (ROOT . '/library_Easy/mysqlhelper.php');
<?php // include_once (ROOT . '/library_Easy/mysqlhelper.php');//固定写法 class MessageList extends MySqlHelper { public function __construct() { parent::__construct("message_list");//和数据库一致 } } ?> |
2.在项目新建文件夹text,在文件夹下建文件PHP.web
include_once '../library_Easy/config_Self.php'; include_once '../model/message.php'; //StaffList::IsLogin(); //判断是否登录不用打开 |
3.增append
$username=new MessageList();//实例化一个对象 $username ['my_id'];//数据库id设置自增 $username ['username']=bonly8; $username ['passage']=123456; $username->append()->submit(); |
删除delete
$username=new MessageList();//实例化一个对象 $username->delete()->where('my_id=6')->submit(); |
修改update
$username=new MessageList();//实例化一个对象 $username['password']=334456;//将id=6的数据修改password这一列的值为334456 $username->update()->where('my_id=6')->submit(); |
查询
$username=new MessageList();//实例化一个对象 $username->select ()->where('my_id=6')->get_first_rows (); echo $username['username'];//输出 |
按照升序输出
$username=new MessageList();//实例化一个对象 $username->select()->get_page_asc('my_id');//按照升序输出 <?php while($username->for_in_rows()){ echo $username['my_id']; echo $username['username']; echo $username['password']; ?> |