I have a db table called “packs” (pack_id, pack_name, pack_description, pack_image)
My packs.php model:
<?php defined('SYSPATH') or die('No direct script access.');
class Model_Packs extends ORM {
}
My packs.php controller:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Packs extends Controller {
public function action_index($pack_name = null)
{
$view = new View('packs/index');
$this->response->body($view);
}
public function action_pack()
{
$pack_name = $this->request->param('id'); //get the packname from uri
$pack = ORM::factory('packs')->where('pack_name', $pack_name)->find();
print_r($pack);die;
$view = new View('packs/index');
$this->response->body($view);
}
} // End of file
Calling http://www.mysite.com/packs/pack/aPackName , Kohana throws this error:
Database_Exception [ 1146 ]: Table ‘packs_db.packses’ doesn’t exist [ SHOW FULL COLUMNS FROM ‘packses’ ]
I checked my database.php conf file, everything’s ok.
Why da hell is kohana adding “es” at the end of the table name?? I am completely puzzled…
It seems kohana is trying to be “smart” and guess what’s the table name based on class name.
if you rename your model to
Model_PackIt should do the trick. Other solution is to give your model table name.