Eddie
Eddie

Reputation: 305

Kohana - Incorrect table name - issue

I'm running Kohana stable release 3.2.0, just downloaded. My database configuration is done and bootstrap contains orm and database modules enabled. So is my model created.

My request looks like this:

$user = ORM::factory('user',$post)->find();
if($user->count_all()){
 echo '<pre>';
 print_r($user);
 echo '</pre>';
}

Basically it should return some data, but it gives me an error.

Database_Exception [ 1103 ]: Incorrect table name '' [ SELECT COUNT(*) AS `records_found` FROM `` ]

Is this normal, that it displays empty table?

  1. If I update configuration with table prefix, it displays prefix, but does not show table.
  2. If I update model with protected variable $table_name='user'; it still does not see it.

Upvotes: 0

Views: 531

Answers (1)

biakaveron
biakaveron

Reputation: 5483

$user = ORM::factory('user',$post)->find();
if($user->loaded()){
 echo '<pre>';
 print_r($user);
 echo '</pre>';
}

Use loaded() method to check that user was successfully loaded from DB.

Upvotes: 1

Related Questions