CodeIgniter自定义通用路由器类

I'm trying to "shorten" my URLs, for example from:

http://mydomain.com/controller/method/something-here

into

http://mydomain.com/something-here

by adding to routes.php:

$route['(.*)'] = 'router/resolve/$1';

and creating a Router class, whose resolve() method determines whether something-here matches a row in one of my database tables (entities). If so, I want to load the entry by calling the appropriate controller::method.

For example, if something-here is a type of book, I'd like Router::resolve() to call Book::view($id).

However, I realize it's not possible for a controller to call the method of another controller. (Is it?)

I also cannot use redirect("book/view/$id") because $route['(.*)'] will call Router::resolve() on book (the first segment).

Any suggestions on how to achieve my goal?

I can think of two solutions;
1) Use a HMVC architecture, which would allow for calling one controller from another.

2) Dynamically generate your routes.
This may not be the most efficient or elegant solution, but it is an option.

<?php
$route[ 'default_controller' ]  = 'main';
$route[ '404_override' ]        = 'error404';

require_once( BASEPATH .'database/DB'. EXT );
$db =& DB();
$query = $db->get( 'whatever_table' );
$result = $query->result();
foreach( $result as $row )
{
    $route[$row->slug.'/(:any)'] = $row->controller.'/'.$row->method.'/$1';
}

As it has been pointed out to me before, routes are processed using a regex (in _parse_routes) so this may not be the quickest in performance, it depends on how many routes you would be generating and how you feel about the performance impact.