jeudi 13 août 2015

How can I use query in router.php of codeigniter?

I have a list of router such as:

$route['mobile'] = 'parrent_list';
$route['tables'] = 'parrent_list';
$route['laptop'] = 'parrent_list';
$route['gamer'] = 'parrent_list';

My router.php have about 100 row. I dont't want set it manual. So i want know how can I use query in router to get my categories in database. Example:

require_once( BASEPATH .'database/DB'. EXT );
$db =& DB();
$query = $db->get( 'categories' )->where( 'parrent_id', 0 );
$result = $query->result();
foreach( $result as $row )
{
    $route[ $row->slug ]                 = 'parrent_list;
    $route[ $row->slug.'/:any' ]         = 'parrent_list;

}

I try but it don't work. Thanks all.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire