-
Notifications
You must be signed in to change notification settings - Fork 347
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
DB::select() doesn't use readonly instance basically... #2062
Comments
That is the logical result from switching to hardcoded static calls to connection objects. And it needs the connection because that determines the driver, and the driver determines the SQL syntax to be used. The reason it uses the 'default' connection is in the name, it is the default connection. If you don't want that, define another default. If you have a database setup where you have read-only slaves, set them as your default, and use the option in either Model_Crud or the ORM to define both a read-only and a read-write connection, so you don't have this issue anymore. |
I've looked into the code, and I don't see any functional change. We try to take very good care in not breaking backward compatibility, even with a major change like a rewrite of the database layer. None of our applications needed a code change when we introduced it. So I am struggling to understand what exactly your problem is. |
Thank you for reply, and sorry for late reply. And if you cannot understand my English, please let me know, I think I can understand what you are talking about. It can be fixed, if I set readonly instance as default.
So I thought default function should use readonly intances. |
As I said, the change was needed because the classes are no longer used statically, and they now need to know for which SQL dialect the class is instantiated. So if Model_Crud now uses the incorrect database connection, it needs to be changed to adapt to the new database layer, not they other way around. I haven't used Model_Crud myself (ever), so I need to look into the code to see what is needed. |
DB::select() used to return Database_Query_Builder_Select class without connection before,
but now it returns with connection.
And the connection is created by
\Database_Connection::instance()
method.\Database_Connection::instance()
is defined asso the connection is always master one.
Actually I can use readonly instances in some ways like below.
pass arguments to the execute method
DB::select()->...->execute('default')
set the static $_connection field of Model_Crud
protected static $_connection = 'default';
but I think it should use readonly instances, when it is select query.
so I suggest to change the DB::select() method like below
any idea ??
thanks.
The text was updated successfully, but these errors were encountered: