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

[eluser]mmarcus44[/eluser]
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.
#2

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

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.
#3

[eluser]mmarcus44[/eluser]
Im sorry,

here you go:
http://ellislab.com/forums/viewthread/72485/

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.
#4

[eluser]mmarcus44[/eluser]
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
#5

[eluser]mmarcus44[/eluser]
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:password@hostname/database';

$this->load->database($dsn);
#6

[eluser]jedd[/eluser]
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.
#7

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




Theme © iAndrew 2016 - Forum software by © MyBB