Answer the question
In order to leave comments, you need to log in
Kohana 3 and modules?
Good afternoon!
I'm starting to learn kohan using an example written by another programmer. Part of the site written by him works fine and everything is clear in it, I can make my changes / improvements. However, when trying to add my functionality, I ran into the following problem.
I'm trying to combine the new functionality with the existing authorization engine on the site. Created a controller "class Controller_Auth extends Controller" and a corresponding model "class Model_Auth extends Kohana_Model". If the controller is called from the main application to check the visitor's rights, everything works fine. But when I try to use this controller directly, actually for authorization, I step on a rake - the Database module is not loaded and, accordingly, all attempts to access the database cause an error.
For the main application, the routing is specified:
Route::set('forum', 'forum(/(/page))')->defaults(array('controller' => 'forum', 'id' => 1, 'page' => 1));<br/>
<br/>
<br/>
В соответствие с этим был добавлен новый роут:<br/>
<code>Route::set('auth', 'auth(/)')->defaults(array('controller' => 'auth', 'action' => 'login'));<br/>
<br/>
<br/>
Форма отправляется по URL: "/auth/login" и POST-ом отправляются данные. Контроллер и соответствующая модель работают, но возникает ошибка при обращении к БД. При этом в списке загруженных модулей, который kohana показывает на странице с ошибкой, видно, что модуль database не загружен.<br/>
<br/>
Посоветуйте, где найти эти чертовы грабли?</code>
Answer the question
In order to leave comments, you need to log in
It looks like you forgot to write parent::__construct() in the model constructor if you overridden it.
What version of the framework, by the way? 3.0 or 3.1? If 3.1, then the model must be inherited from the Model_Database class.
PS $this->_db I hope is called from the model? What does var_dump($this->_db) show? In general, queries should be made using DB::query(...)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question