PelnaE
PelnaE

Reputation: 69

Where is the mistake - they shows incorrect message

I created function for my blog, but it not works correctly. Controller:

$id_get = Model::factory('index')->get_id($slug);
$this->template->content = View::factory('index/article')
                    ->set('slug', $mysql_respnse)
        ->set('commentars', Model::factory('index')->find_commentars($id_get)); 

View:

    <?php
    if($commentars){
      echo 'There is a commentar!'; 
    }
else{
echo 'There is no any commentar!';
}
    ?>

Model:

public function get_id($slug){
    $query = DB::query(Database::SELECT, 'SELECT id FROM ieraksti WHERE slug = :slug')
            ->parameters(array(':slug' => $slug))->execute()->as_array();
}

Where is the mistake? The script shows 'There is no any commentars!', but I need 'There is a commentar'.

Upvotes: 0

Views: 115

Answers (1)

Darsstar
Darsstar

Reputation: 1895

You do not return anything in the get_id() method of your model. Therefor $get_id has a value of NULL and so does $commentars.

Upvotes: 4

Related Questions