编程语言
首页 > 编程语言> > 任何人都知道不使用PDO的优秀PHP ORM?

任何人都知道不使用PDO的优秀PHP ORM?

作者:互联网

我正在为一个大型大学校园中的一个部门构建一个Webapp,该Webapp最终将在企业服务器上运行(我宽松地使用“企业”一词).

问题是管理员拒绝编译和启用除SQLite之外的任何PDO扩展.他们确实启用了mysqlmysqli,所以这不是全部损失.

那么,这里有没有人知道一个很好的PHP ORM,它不依赖PDO作为其主要引擎?

我已经看过Doctrine和Propel(两个优秀的框架),尽管无法弄清楚如何从它们内部提取PDO.

编辑:这是我从服务器上的管理员那里得到的响应:

Sean,

We have tried, unsuccessfully, several times to build PHP with the PDO extension included. The reason we haven’t been successful is complicated, but basically stems from the fact that the web envoronment was originally set up with some database driver libraries compiled staticly and others compiled dynamically, the mix causing PDO to complain loudly. The reason things were were done this way was due to a bug in early versions of PHP 5.x that is no longer an issue today (or at least less of one), but switching is difficult because the change would require modifications to php.ini files and, since every site (including sites on [server redacted]) has its own php.ini (roughly 22,000 files total, many of which are modified by users) it is very difficult to push out that change (and not making the change causes errors [I don’t recall if they are fatal or not] on pages served from accounts with non-updated files).

解决方法:

我想每个现代的ORM都依赖PDO,因为它是标准的数据库驱动程序.

如果启用了MySQLi extension,则应该能够编写自己的PDO(IIRC MySQLi支持PDO所做的一切).

if (extension_loaded('pdo_mysql') == false) {
    class PDO {
        protected $connection;

        public function __construct($dsn, $username = null, $password = null, array $driver_options = array()) {
            $this->connection = new MySQLi(...);
        }
    }

    class PDOStatement { ... }
    class PDOException extends RuntimeException { ... }
}

您必须实现整个PDO API,但至少可以使用.

标签:orm,web-applications,mysql,php,pdo
来源: https://codeday.me/bug/20191208/2094286.html