[eluser]@MaxG[/eluser]
Hey Guys,
I have created an library to route things from an database dynamically.
Here is the Code(application/libraries/route.php):
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Route{
public $_ci;
public function __construct()
{
$this->_ci =& get_instance();
}
public function GetAllRoutes()
{
$q = $this->_ci->db->get('routes');
return $q->result_array();
}
public function AddNewRoute($RouteId, $RouteStart, $RouteAim)
{
$ToInsert = array(
'route_id' => $RouteId,
'route_start' => $RouteStart,
'route_aim' => $RouteAim
);
If($this->_ci->db->insert('routes', $ToInsert))
{
return true;
}
return false;
}
}
Then in the file(application/config/routes.php):
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$route['default_controller'] = "page";
$route['404_override'] = '';
Foreach($this->route->GetAllRoutes as $GetAllRoutes){
$route[$GetAllRoutes['route_start']] = $GetAllRoutes['route_aim'];
}
/* End of file routes.php */
/* Location: ./application/config/routes.php */
I have autoloaded the library.
The folowing Error comes:
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: MY_Router::$route
Filename: config/routes.php
Line Number: 43
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: config/routes.php
Line Number: 43
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: config/routes.php
Line Number: 43
Oh.. Iam using HMVC(MX).
Would be SO nice, if everyone could help me.
Sorry for my bad bad english, iam german and to stupid to learn it :-D
Greets