Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Let's decide what's actually going into 4.6
etc wrote #294645:
What should I replace
global $DB; mysql_select_db($DB->db);
with to make it both 4.5 and 4.6 compatible? It’s in a plugin, so hosting-independent.
Pseudo-code:
if (version_compare(get_pref('version'), '4.6', '>=')) {
mysqli_select_db($DB, 'dbname');
} else {
mysql_select_db('dbname');
}
Edit: could there be a
safe_
function for this?
No. There isn’t one.
Offline
Re: Let's decide what's actually going into 4.6
gaekwad wrote #294671:
How about this – make a
mysqli-test
branch on Textpattern with the mysqli stuff and then test it against the top twenty plugins from the most active threads in the plugin forum. A few testers could divvy up the work of the top twenty, report back, and then snag some more plugins as time/energy/motivation permits.
It’s much easier than that. Just install the plugins in your current 4.5.7 TXP install, edit the plugin, search for “mysql_” functions. If you don’t find the string “mysql_” anywhere in the plugin, it’ll probably work in 4.6 (apart from the tag registry stuff, but for now that’s just a warning in debug mode).
Offline
Offline
Re: Let's decide what's actually going into 4.6
Turns out it’s a lot easier to check this reliably:
global $DB;
if (is_object($DB->link)) {
// use mysqli_
} else {
// use mysql_
}
This works because $DB->link is a resource when using mysql_ functions, but it’s an object when using mysqli_;
Offline
Offline
Re: Let's decide what's actually going into 4.6
We’ll have to find another trick if/once we switch to PDO instead of mysqli ;)
Offline