PHP medoo怎么样,medoo轻量级的php数据库框架-----常用操作总结

文档地址官方文档

edab27f2c6ca374a5981a76cb6f3aa22.png

中文文档

edab27f2c6ca374a5981a76cb6f3aa22.png

数据分页<?php

$db = new Medoo([

'database_type' => 'mysql',

'database_name' => 'pchome_admin',

'server' => '172.19.198.255',

'username' => 'root',

'password' => 'yxdown@10086',

'charset' => 'utf8mb4',

'collation' => 'utf8mb4_general_ci',

'port' => 3306

]);

$page = isset($_GET['page']) ? $_GET['page'] : 1;

$limit = isset($_GET['limit']) ? min($_GET['limit'], 50) : 20;

$offset = ($page - 1) * $limit;

$count = $db->count($table)

//带条件的查询

//$count = $db->count($table, $where);

/**

* table [string] 表名

* join [array] 多表查询

* column [string] 需要统计的字段.

* where (optional) [array] WHERE 条件.

*/

//$count = $db->count($table, $join, $column, $where); //总条数

$id = $this->db->select($table ,"id", ["LIMIT" => [$offset , $limit]]); //id集合

$list = $this->db->select($table, "*", ["id" => $id]); //请求数据库数据

$totalPage = ceil($count/$limit); //总页数

?>