Location: PHPKode > scripts > Paginator Iterator > paginator-iterator/pi_lib/plugins/mysql.php
<?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_mysql_ds(&$db, $sql, $offset, $limit, &$pi)
{
	try	
	{
		$dataSource=array();
		$sql=str_replace(":OFFSET", $offset, $sql);
		$sql=str_replace(":LIMIT", $limit, $sql);
		if($result=mysql_query($sql, $db))
		{
			while($row=mysql_fetch_assoc($result))
				$dataSource[]=$row;
			mysql_free_result($result);
		}

		return $dataSource;
	}
	catch(Exception $e) {
		throw $e;
	}
}

/**
*	Must to return a number
*/
function pi_mysql_numrows(&$db, $sql, &$pi)
{
	if($result=mysql_query($sql, $db))
	{
		$row=mysql_fetch_row($result);
		return $row[0];
	}

	return 0;
}

?>
Return current item: Paginator Iterator