0
Is there a php function to replace #_
by multiple example table prefixes Test,test2,test3,test4
->from ( '#__dolar_corrent AS a' )->leftJoin ( '#__users' )
0
Is there a php function to replace #_
by multiple example table prefixes Test,test2,test3,test4
->from ( '#__dolar_corrent AS a' )->leftJoin ( '#__users' )
3
Has this:
str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )
Applying to your case:
->from ( str_replace( '#_', 'Test', '#__dolar_corrent AS a' ) ) etc
If you want to number in one loop for example:
$from = '#__dolar_corrent AS a';
$join = '#__users';
for($i = 1; $i < 5; ++$i) {
...
$pref = 'Test'.$i;
->from(str_replace('#_', $pref, $from))->leftJoin(str_replace('#_', $pref, $join));
...
}
Remember that this only makes sense if you cannot change the prefixes. With concatenation it is much simpler:
for($i = 1; $i < 5; ++$i) {
...
$from = 'Test'.$i.'_dolar_corrent AS a';
$join = 'Test'.$i.'_users';
->from($from)->leftJoin($join);
...
}
If you want to omit the 1
leaving Test, Test2, Test3
as in the question, instead of:
'Test'.$i
use:
'Test'.($i>1?$i:'')
in either case.
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
Thank you for having responded. I really wanted to is with a join all 29 prefix I have in a single file. ->from ( '#__dolar_corrent AS a' )->leftJoin ( '#_users' ) the # and a prefix
– valdir silva
The above code changes #_ by Teste1... as requested in the question, outside of what was asked, I have no way to answer, I would have no way to guess what was not said, right :)
– Bacco
I don’t understand what you call a copy of the question. Your question is at the top of the page, asking how to exchange #_ for multiple prefixes. I gave an example of how to exchange one, and how to exchange several based on what is in the question. There speaks nothing of text, nor how many are, nor the criterion. I responded based on what I gave, but whatever it is, I believe it’s easy to adapt to your real case. I suggest, in subsequent questions give more details, so we can be more precise in the answers as well. Here are some tips: [Ask] and something about the Problemaxy.
– Bacco