douwu5009 2014-08-20 15:08
浏览 36
已采纳

没有PHP的配置数据库/存储

For many small applications I need some form of storage and querying, but I'm getting tired of having to create a database and setting up table structures as I usually do with MySQL. I'd rather have a PHP framework / class that would simply write a db-like format through disk IO, no user/pass for 'db' access or database/table configurations.

Performance is not an issue as these apps will hardly be used. Data integrity however would be appreciated.

Is there anything like this available?

  • 写回答

1条回答 默认 最新

  • dongtan7418 2014-08-20 15:19
    关注

    SQLite could be a good middle ground. You'll still need to set up tables, but this can all be kept in very trivial, self-contained code using SQLite's PRAGMA user_version:

    $pdo     = new PDO('sqlite:/path/to/my/database.sq3');
    $version = $pdo->query('PRAGMA user_version')->fetchColumn();
    
    switch ($version) {
        case 0:
            $pdo->execute('CREATE ...');
            ...
            $pdo->execute('PRAGMA user_version = 1');
        ...
    }
    

    This is essentially a self-contained migration system you can easily run every time you connect to the database, which ensures the database schema is set up as needed, which is a minimum of hassle you should accept anyway. It still gives you most of the features of a full SQL server, in a self contained single file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题