1.5 Template Project

The Joomla! Documentation Working Group is running a project to develop detailed reference and tutorial material on Joomla! 1.5 templates.  There is a project page on the documentation wiki where you can see the work in progress and help us by contributing your knowledge.

Who's Online

We have 17 guests online

Help Site License

The Joomla! Help Site content is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution NonCommercial ShareAlike 2.5. Some parts of this website may be subject to other licenses.
Home arrow Developer Manual arrow 11. API Reference arrow [WORKING] mosDBTable->check

[WORKING] mosDBTable->check PDF Print E-mail

Last reviewed: Not reviewed
phpDocumentor

mosDBTable->check

Checks that current object attributes are valid.

This function may be called at any time but in particular is always called by the mosDBTable->save method to validate the data before saving it to the database. Since these validation tests will be specific to a particular table this function will need to be overridden in the derived class for that table as no tests are performed by the parent class and it will always return true.

When overriding this method you must ensure that it returns a boolean value and that any error message to be returned is placed in $this->_error (see example below).

Syntax

boolean check ( )

Examples

Example: In this example the table contains just two fields: $id and $title.  The $title field must not be empty so the check function performs a simple test to verify this.  This will be called whenever the myTable->save function is called.

class myTable extends mosDBTable {
  var $id=null;
  var $title=null;
 
  function myTable( &$db ) {
    $this->mosDBTable( '#__myTable', 'id', $db );
  }
 
  // Overloaded check function
  function check() {
    // check for valid title
    if (trim( $this->title ) == '') {
      $this->_error = "Title cannot be empty.";
      return false;
    }
 
    return true;
  }
 
}

Please report any errors on this page to the Developer Documentation Forum.

Last Updated ( Monday, 25 December 2006 )
 
< Prev   Next >