Welcome Guest, Not a member yet? Register   Sign In
Problem when loading the database manually via command line

Ok I have seen people complain about this in other posts, but they were left unanswered. I really need an answer because I have no other option.

When I manually load the database in my controller with the neccessary config, I am able to run my code from the browser but when I run the code from the command line there is an error with the db object....

Is there something inside the db object that checks to see if the code is being ran from the browser or not, because Im sure everything in my function should be working properly.

[quote author="mmarcus44" date="1254102532"]
... when I run the code from the command line there is an error with the db object....

Could you perhaps be a bit more vague about the nature of the error, as it's way too easy to guess what's going on here with the excessive number of details you've provided.

You've done the right thing, to make this a really challenging question, by not saying what you've done so far to work out the nature of the problem, what you're seeing in the log files, and indeed what you actually mean by 'loading the database manually via command line'.

If you mean 'run a PHP/CI script using the CLI version of PHP' .. then make sure you don't reveal the differences between your apache and cli versions of the php.ini file -- that would give it all away.

Im sorry,

here you go:

My poblem is the exact same problem that this guy is having.

If you read the third post down it says exactly what Im experiencing.

BTW your sarcasm is funny.

If the database library is autoloaded then the function im trying to run will work good in both the browser AND command line....

If I choose to load the database manually, the function will run via the browser but NOT the command line.... here is an example error im getting from the command line:

fatal error: Call to a member function query() on a non-object

figured out the answer to this problem..... its actually 2 problems in one

for anyone out there thats pulling their hair out...

when you run php via command line make sure youre running the right version (on mac osx you have to do i t like this:
/Applications/MAMP/bin/php5/bin/php index.php

also you MUST use DSN to load the db not the regular way

$dsn = 'dbdriver://username:[email protected]/database';


Oh, you're on a Mac .. that explains a lot. Wink

Quote:/Applications/MAMP/bin/php5/bin/php index.php

You can run 'which php' to identify what binary it uses - that may be useful if you want to track it down (and perhaps remove it - or modify your path order) so that you don't need to type all that in each time.

[eluser]Phil Sturgeon[/eluser]
I always have to set my hostname to "" instead of localhost when using MAMP on the command line. Not an issue with CodeIgniter.

Theme © iAndrew 2016 - Forum software by © MyBB