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/utilities.html', '', '3.14.247.231', 1734782859) in /home/miphpf/domains/miphpf.com/public_html/includes/database.mysql.inc on line 121
Utility classes | MIPHPF - Your Open Source RAD PHP Framework
Skip navigation.
Home

Utility classes

: 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.

miUtil class contains only two methods - getDBArray() and sendEmail(). Examples for using them follows

* getDBArray() example

<?php
// After execution $userNames will be associative array.
// For each element key is the value of UserID field, and value - the value of UserName field.
$userNames = miUtil::getDBArray('SELECT UserID, UserName FROM Users', 'UserID', 'UserName');

print_r($userNames);
// Will output something similar to:
// Array
// (
//     [3] => John Smith
//     [4] => John Doe
//     [7] => Evan Sims
// )
?>

* sendEmail() example
<?php
$to
= 'someone@google.com';
$from = 'me@google.com';
$subject = 'This is a test e-mail';
$body = 'This is the email body text';

miUtil::sendEmail($to, $from, $subject, $body)
?>

miUIUtil class has four methods - templetizeRows(), transposeRows(), createDropdownFilter() and getConstDropdown()
* transposeRows() and templetizeRows() are used when array retrieved from recordset object will be used with template section object
<?php
// Get the records from the database
$idArray = array('1', '3', '5');

$recordset = new miSqlRecordset('Users');
$recordset->addFilter(new miSqlFilterIn($idArray));

$records = $recordset->getRecords();

// Prepare the template section object
$recordsCount = sizeof($records);
$records = miUIUtil::templetizeRows(miUIUtil::transposeRows($records));

$section = new miTemplateParserSectionInfo('records', $recordsCount, $records);
?>

* Add drop-down filter in the table
<?php
class ClientTaskDataManager extends miDataManager {
       
   
public function addTableFeatures($table)
    {
       
parent::addTableFeatures($table);
       
       
// Prepare the filter options
       
$taskStatuses = array(
           
'all' => 'All',
           
'completed' => 'Completed',
           
'not_completed' => 'Not completed'
       
);
       
// Create the actual drop-down filter
       
miUIUtil::createDropdownFilter($this, $table, 'TaskStatus', $taskStatuses, 'taskStatus');

       
// Link the filter clause with corresponding SqlFilter class
       
$this->getTableFilterObj()->setConditionHandler('taskStatus', 'TaskStatusSqlFilter');
    }
}
?>

* Create a static (not database driven) select box
<?php
class EmployeeTaskDataManager extends miDataManager {
   
public function addTableFeatures($table)
    {
       
parent::addTableFeatures($table);

       
// Prepare the select box options
       
$taskStatuses = array(
           
'' => 'Select new status',
           
'inprogress' => 'In Progress'
            'waiting'
=> 'Waiting'
            'completed'
=> 'Completed',
        );

       
// Get the select box HTML code
       
$selectBox = miUIUtil::getConstDropdown('ChangeStatusTo', '', $taskStatuses);
       
// Add it as a table element
       
$table->assign('%%HTML_CHANGESTATUSTODRODOWN%%', $selectBox);
    }
}
?>