-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insufficient connection checking in getUpdateSql() / getInsertSql() #994
Comments
Connection checking may be an across the codebase issue.
Got PHP Warnings & stack traces. Example Code: $driver = 'mysqli';
$db = newAdoConnection($driver);
print "ADOdb Ver: " . $db->Version()."\n";
$db->debug = true;
// No Connection, Valid and Invalid Table / Field
print "ADOdb Error: " . $db->ErrorMsg()."\n";
print "DB Server Desc: " . $db->serverInfo()['description']."\n";
print "DB Server Ver: " . $db->serverInfo()['version']."\n"; It seems that some functions assume that if we have an We may want to provide a general not connected error message, that we could use in other places in the codebase. How do we want to word it? |
That depends on how you look at it. Attempting to use most of the ADOConnection object's methods without a connected database does not make any sense, and IMO is most likely an error / design problem in the client code that should check the connection's status before continuing. As the documentation says
With this in mind, I believe it's probably a good thing to have ADOdb throw some kind of error instead of displaying a nice and gentle error message, sometimes a hard fail the right thing to do... And it avoids having to add an extra to check this in pretty much each and every ADOConnection method, which I'm not sure is worth the effort and overhead in CPU cycles. At some point we're going to move towards Exceptions, and when that happens ADOConnection::connect() will probably throw instead of returning false. |
I understand, wrapping every method in connection checking code is a lot of work. It's out of scope for this issue, but adding connection checking to the Ok, back to the issue at hand. However trying to test #993 did raise the point.
The question is, what would we want
I'm thinking of issues like #875 where better error messages provided by ADOdb would go a long way towards troubleshooting. |
I don't think that adding any more load to execute () is appropriate. For users who need the safety the autoexecute() method provides additional layers of validation. We've spent a good bit of time increasing the speed of the function by adding things like recordset caching. As execute is the lowest level of record manipulation we provide it has to assumed that a robust connection is in place for db access |
OK, are we keeping connection checking for
I'll close down #993, this issue, & #996 if we are not going to do any connection checking. I don't wish to waste our collective time building things for ADOdb that are neither needed or wanted, aka backports to the 5.20x line. LOL! 😄 |
It's out of scope for this issue, but was also exposed by my testcase for #993, code that never ran as expected. Is table & field checking for |
Description
When trying to build a testcase for #993 it was discovered that these functions do not check the connected state of the passed
AdoConnection
object.GetInsertSQL()
throws warnings,GetUpdateSQL()
crashes.Environment
Steps to reproduce
Detailed, step-by-step instructions to reproduce the behavior, including:
Expected behavior
Expected to see the 6 error messages based on
ADODB_BAD_RS
.Additional context
Related Issues: #899 #993
If this is something that would be considered critical, I'll provide backports.
The text was updated successfully, but these errors were encountered: