I need a help with codeigniter, I have in controller in public function index()
this
$data['book'] = $this->db->query(*something*)->result();
and it's normally working but when I want to use it in other function. for example in public function bookshelf()
it wrote me "variable $data seems to be unused in it's scope" and it's not working
How do I use $data
from bookshelf()
function ?
edit: It's working now.
设置和获取时,与$this
$this->data['book'] = $this->db->query(*something*)->result();
create a search function
public function Search ($query){
return $this->db->query($query)->result();
}
use it anywhere
public function index(){
$data['search'] = $this -> Search ("%query%");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.