CodeIgniter Forums

Full Version: database_exists not working -- CI Newb here
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!
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'
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 ?