BaseConnection::$swapPre |
I don't understand the meaning of the swapPre property.
It works in conjunction with DBPrefix (replaces DBPrefix). It is configured in the config. It cannot be set/changed dynamically (there is no public method). Can someone explain with a real example? Quote:A default table prefix that should be swapped with dbprefix. This is useful for distributed In my understanding, when you have a query like "select * from foo_table", if you set DBPrefix = 'db_' and swapPre = 'foo_', you can get the query "select * from db_table". (01-22-2022, 10:22 PM)kenjis Wrote: In my understanding, when you have a query like "select * from foo_table", if you set It works like this. PHP Code: $db->table('table')->select('table.baz'); // SELECT table.baz FROM table But if we use static SQL PHP Code: $db->query('SELECT db_table.baz FROM db_table'); Configs is an entity that rarely changes. From this point of view, it is easier and more efficient to change the static SQL. In my opinion, this transformation is meaningless. At least I did not find a real need for this functionality. So I want to know a real use case.
When you have an app with using the query() method and having prefixed (`db_`) table names,
You have a query like `SELECT db_table.baz FROM db_table`. And you or someone wants to use the app with the different environment that has the different DB prefix `foo_`, DBPrefix and swapPre makes the query `SELECT foo_table.baz FROM foo_table`. Quote:This is useful for distributed |
Welcome Guest, Not a member yet? Register Sign In |