Menu

CUBRID PHP API Persistent Connection

Developers
2011-05-11
2013-06-05
  • Esen Sagynov

    Esen Sagynov - 2011-05-11

    Hello thorny-road,

    Could you please comment on persistent connection in CUBRID PHP API? Is there any plan to support it? And why it hasn't yet been implemented?

     
  • thorny-road

    thorny-road - 2011-05-12

    Hi kadishmal,

    I have considered adding the support for persistent connection. But I found that CCI has already supported it. I can implement the persistent connection in PHP, but I believe it is better to implement it in CCI. :)

    Although CCI supports persistent connection, it is not enough.

    First, the configuration of persistent connection is in cubrid_broker.conf. There are three configurations in cubrid_broker.conf that are related to CCI, including KEEP_CONNECTION, STATEMENT_POOLING and CCI_PCONNECT. It is all right. But the problem is that we can’t setting them in CCI APIs when programming with CCI. When implementing persistent connection in PHP, maybe it is strange to let user change CCI_PCONNECT in cubrid_broker.conf to enable it. It is better to enable or disable it by calling PHP methods.

    Second, we can’t setting the size of CCI connection pool. In CCI, the value of CCI_MAX_CONNECTION_POOL is 256. I think we should give user the chance of setting the size of connection pool before any connection is established if persistent connection is enabled.

     
  • Esen Sagynov

    Esen Sagynov - 2011-05-12

    So, what are your suggestions? What should we do to bring this issue forward? Maybe we should submit a feature request. Have you looked at how MySQL pconnect is implemented, I mean how they configure persistence?

    I am writing about CUBRID PHP, so I need to indicate if we support persistent connection or not. Should I write that at this moment CUBRID PHP API does not support persistent connection?

     
  • thorny-road

    thorny-road - 2011-05-12

    The CUBRID PHP can support persistent connection now. The only problem is that it can't be set by using PHP APIs. We can tell use to enable CCI_PCONNECT in broker configuration, if they want to use persistent connection now.

    The pconnect in MySQL is totally implemented in MySQL PHP Client. We can also implement it in CUBRID PHP, but considering CCI has already implemented it, I think it is better to improve the CCI implementation.

     
  • Esen Sagynov

    Esen Sagynov - 2011-05-12

    Could you please send me a short guide with an example of how a user should establish a persistent connection. You can possible add this guide to the PHP API manual, too. I will wait for you.

    Thanks.

     
  • thorny-road

    thorny-road - 2011-05-12

    There are several CUBRID broker configurations which will affect the behavior of CUBRID PHP functions.

    STATEMENT_POOLING
    CCI_PCONNECT
    KEEP_CONNECTION

    Read CUBRID Manual at http://www.cubrid.org/manual/831/en/Parameter%20by%20Broker for more detailed information.

    If you want CUBRID PHP to support persistent connection, you can enable the CCI_PCONNECT and KEEP_CONNECTION. For example, if your application will connect to the port 33000, you can configue the cubrid_broker.conf like this:

    SERVICE                          =ON
    BROKER_PORT             =33000

    KEEP_CONNECTION    =ON
    CCI_PCONNECT            =ON

    Remember to restart the broker for the changes to take effect. Then the database connection established by cubrid_connect will be persistent, which will still be available even if you call cubrid_disconnect.

     
  • thorny-road

    thorny-road - 2011-05-12

    In addition, please note that the max number of persistent connections in connection pool is 256. If the number of connections is equal to the max number. The following connections comes will not be persistent.

     
  • Esen Sagynov

    Esen Sagynov - 2011-05-12

    Thanks! This is a great quick guide! :) I will include it, too.

     

Log in to post a comment.

Auth0 Logo