How Zend DB manages database connections

I use the Zend Framework for my PHP development, and here is a small function that I used to execute the request. This is not a mistake. The code and everything works fine. But I want to know some concepts of this.

/** 
    * Get dataset by executing sql statement
    * 
    * @param  string $sql - SQL Statement to be executed
    * 
    * @return bool 
    */
    public function executeQuery($sql)
    {
        $this->sqlStatement = $sql;

        if ($this->isDebug)
        {
            echo $sql;
            exit;
        }

        $objSQL = $this->objDB->getAdapter()->prepare($sql);

        try
        {           
            return $objSQL->execute();

        }
        catch(Exception $error)
        {

            $this->logMessage($error->getMessage() . "  SQL : " .$sql);
            return false;
        }
        return false;
    }

The following are obscure areas for me.

  • How does Zend_Db_Table_Abstract support database connections?
  • Is this creating a new connection all the time when I call this function or does it have a connection pool?
  • I did not write any encoding to open or close the database connection. So will the zend framework automatically close connections?
  • If this open and closed connection works all the time, if I perform this function, is there a performance problem?

.

+5
1

Adapter . . , . , , , .

, getConnection(). , PHP. , - PDO-, getConnection() PDO .

, , , . , , , , .

, , , . , , , Zend_Db_Select. , , Zend_Db:: ALLOW_SERIALIZATION FALSE, . . , , . getConnection(). , Zend_Db:: AUTO_RECONNECT_ON_UNSERIALIZE TRUE .

. PHP . .

, PHP script, , , , . closeConnection() , .

1.7.2 , isConnected(). , . , , . , . . 1.7.2 PDO, .

+15

All Articles