php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: peclbugs at festzeit dot ch
New email:
PHP Version: OS:

 

 [2006-11-03 05:39 UTC] peclbugs at festzeit dot ch
Description:
------------
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] )
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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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.

//Mikael
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Sep 21 17:01:23 2020 UTC