Welcome Guest, Not a member yet? Register   Sign In
database_exists not working -- CI Newb here
#1

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!
Reply
#2

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'

Reply
#3

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 ?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB