我实际上陷入了三层结构.我浏览了互联网,发现了两个术语"数据库抽象层"和"数据访问层".
两者有什么不同?
在一些现有代码上,我有以下语句(经过相当长的查询构建练习):
return $statement->fetchAll(
DBAL\FetchMode::CUSTOM_OBJECT,
PublishedLead::class
);
Run Code Online (Sandbox Code Playgroud)
该作品(到目前为止),但我现在都可以看到fetchAll(),并FetchMode都因为DBAL 2.11弃用:
// ResultStatement::fetchAll()
/*
* @deprecated Use fetchAllNumeric(), fetchAllAssociative()
* or fetchFirstColumn() instead.
*/
Run Code Online (Sandbox Code Playgroud)
// FetchMode
/*
* @deprecated Use one of the fetch- or iterate-related
* methods on the Statement
*/
Run Code Online (Sandbox Code Playgroud)
为了保持我的代码尽可能向前兼容,如何编写它以将结果提取到自定义对象中?我是否必须根据结果编写自定义保湿逻辑,或者 DBAL 可以为我做这件事吗?
我用symfony2和doctrine用命令反向设计我的数据库:
php app/console doctrine:mapping:convert
php app/console doctrine:mapping:import
php app/console doctrine:generate:entities
Run Code Online (Sandbox Code Playgroud)
但我的字段被映射为布尔值而不是tinyint(2).
为什么它映射为布尔值?
Doctrine\DBAL\Connection::ping()
我发现这个提交引入了它,但没有给出有关此方法的后继者的信息。
我想知道此功能的预期替代方案是什么。
我应该只是依靠吗isConnected()?