/** * Set the database adapter object * * @param Adapter\AdapterInterface $db * @return Sql */ public function setDb(Adapter\AdapterInterface $db) { $this->db = $db; $adapter = strtolower(get_class($db)); if (strpos($adapter, 'mysql') !== false) { $this->dbType = self::MYSQL; $this->quoteIdType = self::BACKTICK; $this->placeholder = '?'; } else { if (strpos($adapter, 'oracle') !== false) { $this->dbType = self::ORACLE; $this->quoteIdType = self::DOUBLE_QUOTE; $this->placeholder = '?'; } else { if (strpos($adapter, 'pgsql') !== false) { $this->dbType = self::PGSQL; $this->quoteIdType = self::DOUBLE_QUOTE; $this->placeholder = '$'; } else { if (strpos($adapter, 'sqlite') !== false) { $this->dbType = self::SQLITE; $this->quoteIdType = self::DOUBLE_QUOTE; $this->placeholder = ':'; } else { if (strpos($adapter, 'sqlsrv') !== false) { $this->dbType = self::SQLSRV; $this->quoteIdType = self::BRACKET; $this->placeholder = '?'; } } } } } if ($this->db->isPdo()) { $this->placeholder = ':'; if ($this->db->getDbtype() == 'sqlite') { $this->dbType = self::SQLITE; $this->quoteIdType = self::DOUBLE_QUOTE; } else { if ($this->db->getDbtype() == 'pgsql') { $this->dbType = self::PGSQL; $this->quoteIdType = self::DOUBLE_QUOTE; } else { if ($this->db->getDbtype() == 'mysql') { $this->dbType = self::MYSQL; $this->quoteIdType = self::BACKTICK; } } } } return $this; }