Welcome Guest, Not a member yet? Register   Sign In
access to database from models
#1

[eluser]Unknown[/eluser]
Hi, i have a problem.
I write my class in models/content.php
Code:
class Content extends Model
{
    public function __construct()
    {
        parent::Model();
    }
    
    public function display_content($site)
    {    
        $query = $this->database->query('SELECT name, content FROM content WHERE name="{$site}"');
    }
}
and it shows me an error
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Content::$database

Filename: models/content.php

Line Number: 13

What should i do, if i want to use CI database class inside 'models' folder ?
#2

[eluser]WanWizard[/eluser]
Use
Code:
$this->db->...
?
#3

[eluser]Unknown[/eluser]
oops :roll: my bad.. sorry, and thanks for quick answer

ps: I promies that i will be more carefully in reading user guide.




Theme © iAndrew 2016 - Forum software by © MyBB