public function initialize(array $config)
 {
     parent::initialize($config);
     $this->addAssociations(['hasMany' => ['Articles']]);
 }
Example #2
0
// Include database connection.
include 'easypager.php';
// Include main pager script.
/***  Create a new table object. It accepts three parameters 

			// database connection variable.
			// table name.
			// number of records to show in one page.

	**/
$x = new Table($con, "oc_country", 30);
/** Set the table properties. The properties method accepts two parameters as array.

		//  Table header's names.
		//	Columns to show and their order. (This is an optional parameter. Default is all columns as per their order in databse table.)

	**/
$x->properties(array("ID", "Name", "Designation"));
// Shows the database table columns as it is in the db.
$x->properties(array("ID", "Name", "Designation"), array(0, 1, 4));
// Shows only first, second and fifth fields from database.
$x->properties(array("ID", "Name", "Designation"), array(0, 4, 1));
// Shows only first, second and fifth fields from database in (first, fifth, second) order.
/** Initialize the table to show. This method takes no parameters and calling this method is mandatory. **/
$x->initialize();
/** generate the table. **/
$table = $x->generate_table();
/** Show the table **/
echo $table;
/** Additionally the debug_vars(); method shows the variable values for debugging purpose **/
$x->debug_vars();