-
Notifications
You must be signed in to change notification settings - Fork 19
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
How to use $this->subquery->defaultDB() ? #7
Comments
That code looks correct, it should be working. |
After you call |
Based on my code above, here is the query SELECT (SELECT `number` FROM (`db2`.`db_numbers`) WHERE `numberID` = 2) AS `number` FROM `db`.`db_mytable` I expect it to be SELECT (SELECT `number` FROM (`db2`.`db2_numbers`) WHERE `numberID` = 2) AS `number` FROM `db`.`db_mytable` |
AH! I forgot about database prefixes. Might take a few days, but I'll get it fixed :-) P.S. Don't you mean |
Oh you are right. Sorry for making you confused to my code. Nevermind, for a while, I will try to add parameter function start_subquery($statement, $join_type='', $join_on=1, $defaultDB = ''){
$db = $this->CI->load->database($defaultDB, true);
$this->dbStack[] = $db;
$this->statement[] = $statement;
if(strtolower($statement) == 'join'){
$this->join_type[] = $join_type;
$this->join_on[] = $join_on;
}
return $db;
} Thanks for giving time to response this issue and fixing the code. :-) |
I knew what you meant, it's all good. Your fix seems like it would work just fine. :-) (If you want to fork my repo and send me a pull request, feel free) Just remember to do:
I was thinking, I might make a |
Honestly I do not have idea how to tell it programmatically, but basically I prefer the prefix is configured automatically by retrieving prefix from database config (not configured manually by user when using the function). Anyway the defaultDB function is supposed to do that, isn't it? |
I found that there is a function, that when called will give you the table name, correctly prefixed. If I use that, then it should work as you expect. Pass an object to I'll play with it in the next few days, expect an update soon. :-) |
Ok, I think I got it working. I modified the code so that the |
Cool! It works! Thanks :-) |
Pardon for my beginner in object oriented PHP Codeigniter. I am confused about using $this->subquery->defaultDB() ?
but the subquery still use the default database not db2. Thank you.
The text was updated successfully, but these errors were encountered: