CodeIgniter Forums
database_exists not working -- CI Newb here - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forum-6.html)
+--- Forum: Issues (https://forum.codeigniter.com/forum-19.html)
+--- Thread: database_exists not working -- CI Newb here (/thread-1637.html)



database_exists not working -- CI Newb here - ant099 - 03-27-2015

I'm building an site that needs to build a database table on the fly the first time a user visits a certain page. I'm trying to detect if the table already exists before going through the hassle of building the table.

I am loading the
Code:
dbutil()
in the controller.

Then to do the test:
PHP Code:
if( !$this->dbutil->database_exists($answerDB) ){
  
CREATION CODE HERE 


with
Code:
$answerDB
being the table name that I'm testing for/trying to create.

The problem is that
Code:
$this->dbutil->database_exists(
) returns false every time, even if the table exists.

Should be straight forward but for some reason I'm missing something....

Any help is much appreciated.Thanks!


RE: database_exists not working -- CI Newb here - Rufnex - 03-28-2015

Have you checked your spelling? This works fine for me

PHP Code:
$this->load->dbutil();
echo (
$this->dbutil->database_exists('my_db_name')) ? 'exists' 'nothing'



RE: database_exists not working -- CI Newb here - sintakonte - 03-31-2015

if i read it correctly it looks like you check if an Database exists rather than the table exists or am i missing something here ?