/var/www/agiletoolkit.org/_/codepad/atk4/lib/Controller/Data/Array.php:264 [2] reset() expects parameter 1 to be array, null given
/var/www/agiletoolkit.org/_/codepad/atk4/lib/Controller/Data/Array.php:283 [2] Variable passed to each() is not an array or object
Agile Toolkit

Creating your own Data Controller

The core package of Agile Toolkit provides a basic support for NoSQL models (non-relational models). There are no standard API or language therefore controllers must exist which will help integrate standard model actions with your database of choice.

Some of the storage methods are based around array access, and therefore make use of existing Data_Array controller. The following example implements Data_Sesion controller which will store data in the standard PHP session.

SOURCE

class Controller_Data_Session extends Controller_Data_Array {
	function setSource($model,$ref){
		session_start();
		if(!$_SESSION[$ref])$_SESSION[$ref]=array();
		$model->table=&$_SESSION[$ref];
	}
}

  
Demo
The example was executed successfully, but did not produce any output

Controller and table identifier are specified through setSource. The example below:

SOURCE

$m=$page->add('Model');

$m->setSource('Session','test');
$m->addField('surname');

$page->add('CRUD')->setModel($m,array('id','name','surname'));

  
Demo
Surname Edit Delete
No matching records to display