在Symfony控制器的操作中,如何找出当前使用的数据库驱动程序?就像是
public function testAction(Request $request)
{
// How to accomplish this?
switch ($this->getDoctrine()->getDriverName()) {
case 'pdo_mysql':
// execute MySQL-specific query…
break;
case 'pdo_sqlite':
// execute SQLite-specific query…
break;
default:
// …
}
return $this->render(/* … */);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
329 次 |
| 最近记录: |