CodeIgniter Forums

Full Version: Database driven urls
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In CI3 I use following code in routes.php:
PHP Code:
require_once( BASEPATH .'database/DB'EXT );
$db =& DB();
$url trim($_SERVER['REQUEST_URI'],'/');

$query_res $db->query("SELECT * FROM `routes` where name = ?");
$row $query_res->row();
$route[$url] = $row->path;

for database driven routes.
How can I store routes in DB in CI4?
I want use routes like for different controllers
It's the same, but different names.

PHP Code:
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------

$db  Database::connect();
$res $db->query("SELECT * FROM `routes` WHERE `name` = ?"$name);
$res->getResult() as $row)
// ...