Notice: Undefined offset: 8192 in /home/miphpf/domains/ on line 499

Notice: Undefined offset: 8192 in /home/miphpf/domains/ on line 506
Actions | MIPHPF - Your Open Source RAD PHP Framework
Skip navigation.


: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/miphpf/domains/ on line 291.

Actions abstract the operations performed by the user, keeping the processing code clean and tidy.

Action is specified by GET/POST variable named 'action' which contains the action name (e.g. "/cart.php?action=dmCreate" sends dmCreate action to the data manager). As a result, action object is created by the data manager to process the action. To execute the action the data manager calls the action object's doAction() method. There are two base action classes -  miAction and  miActionWithWebForm.

miAction is the base class for all action objects
miActionWithWebForm is subclass of miAction and is used when a web form is to be displayed or submitted (e.g. when creating/editing record).

To implement specific functionality derive the class from  miAction or  miActionWithWebForm and override the doAction() method (the method should return true on success, or false on error).
Also the new action class should be registered with the data manager by calling setActionHandler() method of the data manager object. This will assign specific action class to handle a specific action (e.g. dmEdit action is handled by miEditAction class).

MIPHPF includes a number of standard action classes for the most common situations - create, edit, delete and list records.

* Assigning new action handlers

class miAddToCartAction extends miAction {
public function doAction()
$productId = miGetParam('ProductID');
$productQuantity = miGetParam('ProductQuantity');

miCart::addProductQuantity($productId, $productQuantity);

// Redirect to the cart listing page with message 'Success'
        // $this->_controller is reference to the data manager object

// Tell the data manager that operation completed with success
return true;

$recordset = new miSqlRecordset('Products');
$dataManager = new miDataManager($recordset);

$dataManager->setActionHandler('dmAddToCart', 'miAddToCartAction');