Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
rah_swap plugin with table_prefix
I’m attempting to access another TXP database (with a table_prefix) on the same server using rah_swap.
<rah::swap db="a" user="b" pass="c" host="localhost:3306">etc
I’m getting nada, but I suspect its ‘cos I’m not specifying the prefix. I can remove the prefix on the master db, but is there a simpler solution?
Thanks!
Offline
Re: rah_swap plugin with table_prefix
Interesting question. rah_swap just switches the database connection temporarily and the code is so sparing, I can’t tell if setting table_prefix will have any effect. If I’m not mistaken, the table prefix is independent of the connection and is always inserted as part of the database query. When we install Textpattern, it’s asked as part of the installation routine but stored as constant called PFX
that is then used in Textpattern’s database query functions.
Two ideas:
- Use smd_query so that you can specify the table prefix as part of the
table
attribute but then process using txp:tags. - Change the
PFX
constant in atxp:php
block after swapping db connections with rah_swap, the reset it again after returning to your regular database. You can see how that’s done in Textpattern here.
I bet someone else can give you a more authoritative answer :-)
TXP Builders – finely-crafted code, design and txp
Offline
Re: rah_swap plugin with table_prefix
To keep things easy for myself when I revisit this aspect of the code in the future, I think I’ll remove the prefix on the master database (its long been redundant in any case).
Thank you.
Offline
Pages: 1