V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
dvaknheo
V2EX  ›  PHP

thinkphp 的 db 类能剥离出来使用么

  •  
  •   dvaknheo · 2019-07-02 18:46:46 +08:00 · 4607 次点击
    这是一个创建于 1732 天前的主题,其中的信息可能已经有所发展或是发生改变。

    懒得自己写 db 类

    有哪些 DB 类比较好用的

    11 条回复    2019-07-06 16:03:56 +08:00
    ywisax
        1
    ywisax  
       2019-07-02 18:55:40 +08:00
    https://packagist.org/?query=db

    自己 new PDO 是最适合懒人的
    rekulas
        2
    rekulas  
       2019-07-02 19:07:09 +08:00
    有一些独立的 orm 类 比如 notorm 好像有点像
    falcon05
        3
    falcon05  
       2019-07-02 19:10:49 +08:00 via iPhone
    laravel 那个挺好的,可以剥离出来用
    hubqin
        4
    hubqin  
       2019-07-02 20:40:23 +08:00 via Android
    AR ( active record )也不错
    zpfhbyx
        5
    zpfhbyx  
       2019-07-02 20:42:45 +08:00
    medoo?
    sarices
        6
    sarices  
       2019-07-02 20:48:44 +08:00
    iscraft
        7
    iscraft  
       2019-07-03 08:55:23 +08:00
    应该可以 我从 fatfree 里扒出来过一个 注释掉了 cache 相关的
    https://github.com/iscraft/php-pdo-class-of-fat-free
    ben1024
        8
    ben1024  
       2019-07-03 10:00:56 +08:00
    可以剥离,
    Laravel Eloquent 安装下面的软件包就可以
    illuminate/validation
    illuminate/translation
    illuminate/database
    illuminate/support
    illuminate/pagination
    tanszhe
        9
    tanszhe  
       2019-07-03 19:25:16 +08:00
    duola
        10
    duola  
       2019-07-04 18:13:23 +08:00
    medoo 满好的,medoo 作者也在这论坛里。
    dvaknheo
        11
    dvaknheo  
    OP
       2019-07-06 16:03:56 +08:00
    @duola 不认识。上次在 github 讨论议题里加了这个需求,没见回应。


    ```
    class MedooFixed extends \Medoo\Medoo
    {
    public function exec($query, $map = [])
    {
    if (isset($map[0])) {
    array_unshift($map, null);
    unset($map[0]);
    }
    return parent::exec($query, $map);
    }
    }
    ```
    这就可以 $medoo->exec("select * from table_name where name=? and des=? " ,['a','b']);
    方便多了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2904 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:17 · PVG 22:17 · LAX 07:17 · JFK 10:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.