Notice: Undefined offset: 8192 in /home/miphpf/domains/miphpf.com/public_html/includes/common.inc on line 499

Notice: Undefined offset: 8192 in /home/miphpf/domains/miphpf.com/public_html/includes/common.inc on line 506

Warning: Incorrect key file for table './miphpf_miphpfcom/watchdog.MYI'; try to repair it query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', 'preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/miphpf/domains/miphpf.com/public_html/includes/unicode.inc on line 291.', 2, '', 'http://www.miphpf.com/manual/actions.html', '', '3.12.163.23', 1735577662) in /home/miphpf/domains/miphpf.com/public_html/includes/database.mysql.inc on line 121
Actions | MIPHPF - Your Open Source RAD PHP Framework
Skip navigation.
Home

Actions

: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/miphpf/domains/miphpf.com/public_html/includes/unicode.inc 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

<?php
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
       
$this->_controller->addRedirectToListControllerCommand('Success');

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

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

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