Search code examples
classcomponentsjoomla2.5

What a Table Class really does in Joomla! MVC structure?


I'm new to programming Joomla components so will be very glad if someone describe (if possible with an example) the functionality of a table class.


Solution

  • Your XML form (typically located in models/forms). You choose to have the same names as those in your database as those field names but actually it isn't compulsory.

    Table class always extends JTable and api refernce link is JTable. You go through a 3 stage process.

    bind takes the array of data that comes from your form and then stores any data from it into the table class.

    check Method to perform sanity checks on the JTable instance properties to ensure they are safe to store in the database.

    store then stores the binded data into the database table.

    For example we need to some fields of form to database

    public function bind($src, $ignore = array())
    {
        foreach ($src as $field => $value)
        {
            $this->$field = $value;
        }
        return parent::bind($src, $ignore);
    }
    

    It will attempt to match $field to a database column storing the value if it exists.