gpt4 book ai didi

php - 有人知道不使用 PDO 的好 PHP ORM 吗?

转载 作者:可可西里 更新时间:2023-11-01 08:22:08 25 4
gpt4 key购买 nike

我正在为一个大型大学校园的一个部门构建一个 Web 应用程序,该应用程序最终将在企业服务器上运行(我随意使用术语“企业”)。

问题是管理员拒绝编译和启用 SQLite 以外的任何 PDO 扩展。不过,他们确实启用了 mysql 和 mysqli,所以这并不是完全失败。

那么这里有人知道一个不依赖 PDO 作为主引擎的 PHP 的好 ORM 吗?

我已经看过 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,但至少它会起作用。

关于php - 有人知道不使用 PDO 的好 PHP ORM 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4708117/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com