开发者

What do these numbers mean in the PDO object? [duplicate]

This question already has an answer here: What are the numbers in var_dump result? (1 answer) Closed 2 years ago.

I use PDO for my db connection, below is the class that I have been using,

class database_pdo
{
    # database handler
    protected $connection = null;

    # make a connection
    public function __construct($dsn,$username,$password)
    {
        try 
        {
            # MySQL with PDO_MYSQL  
            $this->connection = new PDO($dsn, $username, $password);
            $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
        }
        catch (PDOException $e) 
        {
            # call the get_error function
            $this->get_error($e);
        }
    }

    # don't forget to add getter method to get $this->connection, it's just a good practice.
    public function get_connection()
    {
        return $this->connection;
    }

}

instantiate the db object,

$connection = new database_pdo(DSN,DB_USER,DB_PASS);
var_dump($connection);

result,

object(database_pdo)[1]
  protected 'connection'开发者_JAVA百科 => 
    object(PDO)[2]

on other pages,

object(database_pdo)[4]
  protected 'connection' => 
    object(PDO)[5]

But what I dont understand is - what do the numbers mean? I notice that when the number increases, the slower the server process a page.

How can I avoid these numbers from increasing??


The numbers probably means how many connections you have opened at the same time. Recycle connections or destroy them when you finish with them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜