CakePHP Helper – the fetcher, what we all need, as simple as it is
Sometimes you encounter a place where in a view you need to intiate a model and fetch some information, requestAction is not recommened and currently CakePHP provide a simple way to fetch a model data.
so how can it be done, easily we had made the Fetcher helper that can help you get link, news, users whatever you need from your module writing a few lines of code:
<?php
class FetcherHelper extends AppHelper {
function fetch($model, $options = null, $fetch = ‘all’) {
App::import(’Model’, $model);
$Model = new $model();
return($Model->find($fetch,$options));
}}
?>
usage:
add this helper to your controller, i would recommend to add it to the AppController
and just use in your view: $fetcher->fetch(’Users’,array(’conditions’ => ‘client_id’ => 34));
enjoy.
-
Khozemk
-
gestudio
-
Web Design
-
web hosting
-
Hire PHP Programmer
