(11-29-2014, 05:25 PM)Rufnex Wrote: You have no class defined, so you cannot use the this keyword. This is the way to build a controller (but the db stuff should come from a model).
PHP Code:
class Example extends CI_Controller {
public function __construct()
{
parent::__construct();
}
public function index()
{
$test = $this->db->query("SELECT name FROM users"); // you should hava a where clause to fetch on dataset
echo $test->row()->name; // or call the result by a loop
}
}
You call this with yoursite.tld/example
Ou...yes, it works. But I need to use more queries and I want them to use in all files.
For example:
I have files called header.php, content.php, footer.php, function.php.
I want to use in all files function(). Without function() it works correctly.
Is it possible set up it globally?