|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #57340 assume last connection or connect to default
Submitted: 2006-11-03 05:39 UTC Modified: 2006-11-07 04:29 UTC
From: peclbugs at festzeit dot ch Assigned:
Status: Wont fix Package: memcache (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
42 + 37 = ?
Subscribe to this entry?

 [2006-11-03 05:39 UTC] peclbugs at festzeit dot ch
it would be great if the connections would be handled like with the mysql-functions.

example from the manual:

resource mysql_query ( string query [, resource link_identifier] )
The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If by chance no connection is found or established, an E_WARNING level warning is generated.

right now it's quite cumbersome to keep track of the connection-variable/object when having multiple functions that need it. connecting/closing each time would be slow. having a global-variable and checking the connection each time is complicated...
this would make it much simpler


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-07 04:29 UTC] mikael at synd dot info
The only real difference between the current and the proposed behavior would be that the connection variable would be an implicit global instead of an explicit global, leading to problems such as 
 * Making the code harder to read as there's no way to determine which connection is really used in an environment where multiple connections are a possibility. And even if your application only ever has one connection, what happens the day you or someone would like to use several connections? 
 * Making the code susceptible to hard-to-debug bugs, for example when your application uses the implicit global connection and you for some reason want to open another connection, the application would then switch (perhaps mid-script-execution) to using the new connection
 * No easy way to switch the memcached connection for another, for example for debugging purposes or when migrating to another memcached cluster
 * Encouraging bad coding standards with global variables (having implicit globals is even worse imo)
 * All the memcache_* function take the connection as the first argument, with the proposed feature they would have to have two separate parameter lists leading to increased API and code complexity
 * It is quite possible to do away with global variables or having to send the connection to every function using object oriented techniques, for example each object that need memcached access can be fitted with an $memcached parameter at construction

This feature will not be implemented. However thanks for submitting feedback and if you  have other feature requests in the future, please don't hesitate to report them.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 13:01:28 2024 UTC