current table name for query

Martooti

Member
Hi,
since my problem with limit for list query wasn't solved till now. I made a custom list template where I use the query. The point is that I would like to use it with different tables so I have to override the table that I have with curent table name. Is that possible to do?

As you see below my table name is fb_rightmiddlebanner but how can I get it dynamically?
Columns are the same in other tables.
My query:
Code:
$app = JFactory::getApplication();
    $menu = $app->getMenu()->getActive()->id;
    $db = JFactory::getDbo();
    $db->setQuery("SELECT * FROM fb_rightmiddlebanner WHERE `category`=
(SELECT m.id FROM jos_menu AS m
INNER JOIN fb_rightmiddlebanner AS b ON b.category = m.id
WHERE lft <= (SELECT lft FROM jos_menu WHERE id = $menu)
AND rgt >= (SELECT rgt FROM jos_menu WHERE id = $menu)
ORDER BY rgt LIMIT 1) AND `published`='1';");
$all_banners = $db->loadObjectList();
$banner = $all_banners[0]; ?>
 
Thank you Troester :)
In deed adding $table =$this->table->db_table_name; and then changing table name to $table in the query, make the query works.
 
Just be careful with using common variables like $table, which may well already be in use by Fabrik. It's always safer to use some kind of unique "slug" to prefix any variables you create. I usually have one slug per "project", which I use for all the tables, variables, element names, etc in that project. Typically as short as possible to make typing easy, though.

Then instead of creating a $db, or $table ... it might be $seaDb, or $crocTable, etc.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top