php - CodeIgniter no database selected -


i'm working on this, using crud tutorial:

public function get($id = null, $single = false){      if ($id != null) {         $filter = $this->_primary_filter;         $id = $filter($id);         $this->db->where($this->_primary_key, $id);         $method = 'row';     }     elseif($single == true) {         $method = 'row';     }     else {         $method = 'result';     }      if (!count($this->db->ar_orderby)) {         $this->db->order_by($this->_order_by);     }     return $this->db->get($this->_table_name)->$method(); } 

but got error message:

a database error occurred  error number: 1046  no database selected  select * (`pages`) `slug` = 'about' order `order`  filename: /var/application/core/my_model.php  line number: 34($this->db->get($this->_table_name)->$method();) 

how can choose database?

you need fill out database details in /application/config/database.php

also, if using environments may need edit /application/config/{environment}/database.php file.


Comments