Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6101945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:33:27+00:00 2026-05-23T13:33:27+00:00

In database.php I have: $db[‘default’][‘username’] = IS_PRODUCTION ? ‘prodUsername’ : ‘localDevBoxUsername’; $db[‘default’][‘password’] = IS_PRODUCTION

  • 0

In database.php I have:

$db['default']['username'] = IS_PRODUCTION ? 'prodUsername' : 'localDevBoxUsername';
$db['default']['password'] = IS_PRODUCTION ? 'prodPassword' : 'localDevBoxPassword';

My code is:

function test()
{
    $this->load->database();
    $result = $this->db->query('SELECT * FROM items WHERE description='Oranges');
    echo 'rows:' . $result->num_rows();
}

When I run this in prod it fails.

Now to test it’s not a database config issue, I created a basic PHP file called test.php with:

<?
if (! $db=@mysql_connect ("localhost", "prodUsername", "prodPassword")) 
   die("Error connecting to mysql");

@mysql_select_db("prodDatabase") or die("error connecting to specific database");

$result = @mysql_query('SELECT * FROM items WHERE description='Oranges');
echo 'rows: ' . mysql_num_rows($result);
?>

The php test script works perfectly. The codeigniter code only works for my local dev box but not the prod box. What could I possible be missing????

Update: Please note that although I’m using a constant IS_PRODUCTION in the sample code, this isn’t the problem. I’ve pulled out the values and hardwired them. I just included it to make the example more succinct, that it so show that it works in one environment and not the other

Update2: The issue seems only to be related to the Model. As soon as I move the code to the Controller it works…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:33:28+00:00Added an answer on May 23, 2026 at 1:33 pm

    The issue turned out to be the naming conventions used for the filenames of the models. In my local development environment the case sensitivity required by CodeIgniter wasn’t enforced for whatever reason (some configuration in PHP, etc., I don’t know – I was using xmapp for local desktop development on this specific project). Once the model files were named according to the CodeIgniter specs everything worked as planned.

    Therefore if you’re database code works in the Controller but not in the model, definitely confirm your model file named conventions (as well as class constructors).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

database.php : $db['default']['hostname'] = 192.168.2.104; $db['default']['username'] = webuser; $db['default']['password'] = ----; $db['default']['database'] = vad;
I have a php file which checks for login and password from users database,
i have this PHP code, and a DataBase with Question, answer1, answer2, Question_id well,
I have problem with ajax and php.I have next code $(form).submit(function() { var poruka
Okay. I have this code on my site: <?php session_start(); include database.php; include bruger.php;
I have a PHP code and a field in the database which is a
i have multi database connection default connection is in the database.php $db['default']['hostname'] = 'localhost';
Renaming database.php.default to database.php in \app\Config\ in CAKEPHP gives Error I have installed a
I have a file which I include say: require_once(../../constructor/database.php); $stuff_inside_include_file->doThis() ; //ACCESSIBLE function createUser(){
i have these in Database.php class Database { private $dbname = 'auth'; private $db_instance;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.