Pop\Db\Db::getAdapterType PHP Method

getAdapterType() public method

Get the database adapter type.
public getAdapterType ( ) : string
return string
    public function getAdapterType()
    {
        $type = null;
        $class = get_class($this->adapter);
        if (stripos($class, 'Pdo') !== false) {
            $this->isPdo = true;
            $type = 'Pdo\\' . ucfirst($this->adapter->getDbtype());
        } else {
            $this->isPdo = false;
            $type = ucfirst(str_replace('Pop\\Db\\Adapter\\', '', $class));
        }
        return $type;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Set the database object
  *
  * @param  \Pop\Db\Db $db
  * @return \Pop\Db\Sql
  */
 public function setDb(Db $db)
 {
     $this->db = $db;
     $adapter = strtolower($this->db->getAdapterType());
     if (strpos($adapter, 'mysql') !== false) {
         $this->dbType = self::MYSQL;
         $this->quoteIdType = self::BACKTICK;
     } else {
         if (strpos($adapter, 'oracle') !== false) {
             $this->dbType = self::ORACLE;
             $this->quoteIdType = self::DOUBLE_QUOTE;
         } else {
             if (strpos($adapter, 'pgsql') !== false) {
                 $this->dbType = self::PGSQL;
                 $this->quoteIdType = self::DOUBLE_QUOTE;
             } else {
                 if (strpos($adapter, 'sqlite') !== false) {
                     $this->dbType = self::SQLITE;
                     $this->quoteIdType = self::DOUBLE_QUOTE;
                 } else {
                     if (strpos($adapter, 'sqlsrv') !== false) {
                         $this->dbType = self::SQLSRV;
                         $this->quoteIdType = self::BRACKET;
                     }
                 }
             }
         }
     }
     return $this;
 }