嘿嘿哈哈

Medoo使用
Medoo是一个基于PDO的PHP库,很小巧。这里记录下常用方法。
扫描右侧二维码阅读全文
17
2018/09

Medoo使用

Medoo是一个基于PDO的PHP库,很小巧。这里记录下常用方法。

多表查询

$database->select("post", array(  
    "[>]account" => array("author_id" => "user_id"),  
   
    "[>]album" => "user_id",  
   
    "[>]photo" => array("user_id", "avatar_id")  
), array(  
    "post.post_id",  
    "post.title",  
    "account.city"  
), array(  
    "post.user_id" => 100,  
    "ORDER" => "post.post_id DESC",  
    "LIMIT" => 50  
)); 
SELECT  
        `post`.`post_id`,  
        `post`.`title`,  
        `account`.`city`  
    FROM `post`  
    LEFT JOIN `account` ON `post`.`author_id` = `account`.`user_id`  
    LEFT JOIN `album` USING (`user_id`)  
    LEFT JOIN `photo` USING (`user_id`, `avatar_id`)  
    WHERE  
        `post`.`user_id` = 100  
    ORDER BY `post`.`post_id` DESC  
    LIMIT 50  
Last modification:September 17th, 2018 at 02:30 pm

Leave a Comment