当前位置: 首页>>代码示例>>PHP>>正文


PHP Connection::getServerVersion方法代码示例

本文整理汇总了PHP中Doctrine\DBAL\Connection::getServerVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getServerVersion方法的具体用法?PHP Connection::getServerVersion怎么用?PHP Connection::getServerVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\DBAL\Connection的用法示例。


在下文中一共展示了Connection::getServerVersion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getMergeSql

 /**
  * Returns a merge/upsert (i.e. insert or update) SQL query when supported by the database.
  *
  * @return string|null The SQL string or null when not supported
  */
 private function getMergeSql()
 {
     $platform = $this->con->getDatabasePlatform()->getName();
     switch (true) {
         case 'mysql' === $platform:
             return "INSERT INTO {$this->table} ({$this->idCol}, {$this->dataCol}, {$this->timeCol}) VALUES (:id, :data, :time) " . "ON DUPLICATE KEY UPDATE {$this->dataCol} = VALUES({$this->dataCol}), {$this->timeCol} = VALUES({$this->timeCol})";
         case 'oracle' === $platform:
             // DUAL is Oracle specific dummy table
             return "MERGE INTO {$this->table} USING DUAL ON ({$this->idCol} = :id) " . "WHEN NOT MATCHED THEN INSERT ({$this->idCol}, {$this->dataCol}, {$this->timeCol}) VALUES (:id, :data, :time) " . "WHEN MATCHED THEN UPDATE SET {$this->dataCol} = :data2, {$this->timeCol} = :time";
         case $this->con->getDatabasePlatform() instanceof SQLServer2008Platform:
             // MERGE is only available since SQL Server 2008 and must be terminated by semicolon
             // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx
             return "MERGE INTO {$this->table} WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ({$this->idCol} = :id) " . "WHEN NOT MATCHED THEN INSERT ({$this->idCol}, {$this->dataCol}, {$this->timeCol}) VALUES (:id, :data, :time) " . "WHEN MATCHED THEN UPDATE SET {$this->dataCol} = :data, {$this->timeCol} = :time;";
         case 'sqlite' === $platform:
             return "INSERT OR REPLACE INTO {$this->table} ({$this->idCol}, {$this->dataCol}, {$this->timeCol}) VALUES (:id, :data, :time)";
         case 'postgresql' === $platform && version_compare($this->con->getServerVersion(), '9.5', '>='):
             return "INSERT INTO {$this->table} ({$this->idCol}, {$this->dataCol}, {$this->timeCol}) VALUES (:id, :data, :time) " . "ON CONFLICT ({$this->idCol}) DO UPDATE SET ({$this->dataCol}, {$this->timeCol}) = (EXCLUDED.{$this->dataCol}, EXCLUDED.{$this->timeCol})";
     }
 }
开发者ID:MisatoTremor,项目名称:symfony,代码行数:24,代码来源:DbalSessionHandler.php


注:本文中的Doctrine\DBAL\Connection::getServerVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。