Search code examples
joomla

Joomla 2.5 get data from the table in the Component


I have working on some Component in Joomla 2.5 ( it means I'm trying to write a component in joomla :) ).

My situation is :

I have create the back-end UI which have a table to show some data from database .

My Question is :

How do I get the data which posted by selecting the rows to do some thing on the table.

Details :

My MVC works Find and i routed program after clicking the button to my Model but I don't know how to get the data from that form.

Any help would be appreciated.


Solution

  • Thanks Elin, but the answer which I found after spending some time analyzing other components was:

    1. You should get the data which posted by previous page by this command:

      $jApp = JFactory::getApplication();
      
    2. It is a Array which you should look for specific key "cid" in it by this code:

      $ids  = JRequest::getVar('cid', array(), '', 'array');
      
    3. You have the id of that rows in an array, now you can do something like this:

      foreach ($ids as $i => $id)
      {
        $query = $db->getQuery(true);
        $db->setQuery($query);
        //some code
        $db->query(); // to do change in DB
        $results += $db->getAffectedRows();
      }