简体   繁体   中英

A Database Error Occurred Error Number: 1046 in codeigniter

A Database Error Occurred

Error Number: 1046

No database selected

SELECT * FROM ts_themes WHERE theme_status = 1

Filename: C:/xampp/htdocs/Themeportal/application/models/DatabaseModel.php

Line Number: 23

Manage your database setting in application/config/database.php

$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
'dsn'      => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'database_name',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt'  => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
 );

first configure your database setting application/config/database.php

then your query will be

    $this->db->select('*');
    $this->db->from('ts_themes');
    $this->db->where('theme_status',"1");
    $query=$this->db->get();
    return $query->result();

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM