Welcome Guest, Not a member yet? Register   Sign In
Syntax in function does not work
#13

(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?
Reply


Messages In This Thread
Syntax in function does not work - by lkudlacek - 11-29-2014, 09:23 AM
RE: Syntax in function does not work - by Rufnex - 11-29-2014, 10:26 AM
RE: Syntax in function does not work - by Rufnex - 11-29-2014, 04:36 PM
RE: Syntax in function does not work - by Rufnex - 11-29-2014, 04:50 PM
RE: Syntax in function does not work - by Rufnex - 11-29-2014, 04:54 PM
RE: Syntax in function does not work - by Rufnex - 11-29-2014, 05:10 PM
RE: Syntax in function does not work - by Rufnex - 11-29-2014, 05:25 PM
RE: Syntax in function does not work - by lkudlacek - 11-29-2014, 05:36 PM
RE: Syntax in function does not work - by Rufnex - 11-29-2014, 05:45 PM
RE: Syntax in function does not work - by Rufnex - 12-01-2014, 03:08 PM



Theme © iAndrew 2016 - Forum software by © MyBB