database - CodeIgniter: Fatal error: Call to a member function select() on a non-object -


i getting above error while i'm trying trying access function library shown...

<?php  if ( ! defined('basepath')) exit('no direct script access allowed');  class my_crud {  public function select_from($select, $from) {     // dafaults     $output = "";     // querying     $this->db->select($select);     $this->db->from($from);     $query = $this->db->get();     // if no rows returned     if ($uqery->num_rows == 0) {         return $output = "no results found";     }     // if row(s) retunred     return $output = $query->result_array(); } } 

while database library set autoload.

if creating in library should instance of ci add on __construct

class my_crud {  var $ci;  public function __construct()  {   $this->ci =& get_instance();  } } 

then on method within class change this->db $this->ci->db, question why making crud on library when can make inside model?


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -