-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Enhancement: expose ping() on pingable-connections. #414
Changes from 3 commits
7d77a3f
dc6bad0
11d160b
bffed61
99657f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,11 +20,12 @@ | |
namespace Doctrine\DBAL\Driver\Mysqli; | ||
|
||
use Doctrine\DBAL\Driver\Connection as Connection; | ||
use \Doctrine\DBAL\Driver\PingableConnection; | ||
|
||
/** | ||
* @author Kim Hemsø Rasmussen <kimhemsoe@gmail.com> | ||
*/ | ||
class MysqliConnection implements Connection | ||
class MysqliConnection implements Connection, PingableConnection | ||
{ | ||
/** | ||
* @var \mysqli | ||
|
@@ -207,4 +208,14 @@ private function setDriverOptions(array $driverOptions = array()) | |
); | ||
} | ||
} | ||
|
||
/** | ||
* Pings the server and re-connects when `mysqli.reconnect = 1` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what happens when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stof http://docs.php.net/manual/en/mysqli.configuration.php#ini.mysqli.reconnect Doesn't reconnect. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this means that the effect of calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stof There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @till But the implementation in
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @till @stof Personally, I would throw an exception when there was an error while reconnecting. If automatic reconnecting is disabled in Mysqli it should return false as @stof mentioned, to be consistent in the API. Errors in the physical reconnect should throw an exception IMO as I would expect that from the other driver implementations aswell. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @deeky666 the So the issue here is that we have a different behavior between 2 cases:
Here are my suggestions:
what do you think about it ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't returning boolean false or null (void) but never boolean true an inconsistent return behaviour? I would expect a method that indicates to return a boolean value to return both states. But I agree that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @deeky666 In my proposal, I don't have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stof Alright then I'll agree with you. |
||
* | ||
* @return bool | ||
*/ | ||
public function ping() | ||
{ | ||
return $this->_conn->ping(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing license |
||
namespace Doctrine\DBAL\Driver; | ||
|
||
interface PingableConnection | ||
{ | ||
public function ping(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing phpdoc explaining what the implementation should do |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you implement the method, I would implement
PingableConnection
on this class tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, this is the main connection and not connected (despite naming) with the real connections.