Cloned Connections

2

I would like to know if there is a way to create just one connection to the database to perform the tasks. With each Action executed, a connection is created with the Database and at the end of the Action execution, the connection is closed. So, when it is necessary to execute an Action inside another two connections are left besides the one that was opened for first consultation to the database, thus creating several clones of connection.

I wonder if there is a function that solves this and how to use it. If you need some code to give a better understanding about what I need I put here.

    
asked by anonymous 12.01.2015 / 17:19

1 answer

0

Usually the resource generated by pg_connect is used for all connections. But you do not necessarily need to follow this rule. You can create a connection for each action.

I would do it differently: instead of a connection for each action I would use one transaction per action. Code here .

Using Yii, you will not directly use the PHP postgres functions, but the logic is the same. You have here the way to do this with Yii.

    
13.01.2015 / 12:46