| 
<?php
 /**
 *    Must to return an array like this:
 *    array(
 *        array('id'=>1, 'name'=>'a'),
 *        array('id'=>2, 'name'=>'b'),
 *        array('id'=>23, 'name'=>'')
 *    );
 */
 function pi_mysqli_ds(&$db, $sql, $offset, $limit, &$pi)
 {
 try
 {
 $dataSource=array();
 $sql=str_replace(":OFFSET", $offset, $sql);
 $sql=str_replace(":LIMIT", $limit, $sql);
 if($result=$db->query($sql))
 {
 while($row=$result->fetch_assoc())
 $dataSource[]=$row;
 $result->close();
 }
 
 return $dataSource;
 }
 catch(Exception $e) {
 throw $e;
 }
 }
 
 /**
 *    Must to return a number
 */
 function pi_mysqli_numrows(&$db, $sql, &$pi)
 {
 if($result=$db->query($sql))
 {
 $row=$result->fetch_row();
 return $row[0];
 }
 
 return 0;
 }
 
 ?>
 |