Programming

Folders and Files

Class & Controller

View

Form

Image

PDF

Chart

Database (Single table)

Database (Relational table)

Sort (Drag and Drop)

Image Upload/Display

File Upload/Download

CSV Upload/Download

Database ( How to retrieve data from database) - Filter

Database ( How to retrieve data from database) - Select

Class & Controller

What is a Class?

Class file consists of __construct method and all the other methods related to module.

Example : page(Controller $ctl) method, insert(Controller $ctl) method, update(Controller $ctl) method, etc...

The class file name should be same as the folder name.

What is the Controller?

Cotroller is an interface which specifies the methods, a class should implement.

Example : assign($key,$val) method, POST($key=null) method, close_multi_dialog($dialog_name) method, etc...

First, Let's look at the class file

1) How to use an array in the class file.
2) How to use a database table in the class file.

How to use an array in the class file

The following code show you how to declare and initialize an array.

class helloworld {

private $gender;

function __construct(Controller $ctl){
$this->gender = [0=>"Male", 1=>"Female"];
$ctl->assign("gender",$this->gender);
}

}

How to use a database table in the class file

The following code show you how to declare and initialize a database table connection.

class helloworld {

private $ffm_employee;

function __construct(Controller $ctl){
this->ffm_employee = $ctl->db("employee");
}

}

Let's look at the Controller methods and how to use these methods in the class file.

POST($key=null);

This method is used to retrieve form data using POST method. Following code samples show you how to use this in the class file.

Retrieve all POST data

$data = $ctl->POST();

Retrieve specified POST data

$id = $ctl->POST("id");

show_multi_dialog($dialog_name,$template,$title,$width=600,$hide_ok_button=false,$hide_cancel_button=false);

This method is used to open the multi dialog popup window. This method accepts the dialog name, template name, dialog title, dialog width, hide ok button and hide cancel button as the arguments. Following code sample shows you how to use this in the class file.

$ctl->show_multi_dialog("employee", "employee.tpl", "Employee Details",1000,true,true);

close_multi_dialog($dialog_name);

This method is used to close the multi dialog popup window. This method accepts the dialog name as the argument. Following code sample shows you how to use this in the class file.

$ctl->close_multi_dialog("employee");

FOCUS Business Platform