• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Temporary DB prefix override

#1
Is there a way to override the database prefix for a specific query or duration? or a toggle on-off? Scenario is dozens of tables all prefixed and one library-specific table that isn't, so now all my models are built around the non-prefixed name and I want to write a single CLI Command to access the "external" table but don't seem to be able to do it...
Reply

#2
Quick update on what I've found so far:
* There is a function "setPrefix()" in CodeIgniter\Database\BaseConnection that allows changing the current database prefix; no luck so far getting a model to implement and reset this, but an option for procedural tasks
* Using the database class to write a query directly allows explicitly naming a table sans prefix: $db->query('SELECT * FROM users');
* Using the query builder class *will* always include the prefix: $builder = $db->table("users") - results in "pre_users"

Hope that helps someone
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.