Background: Using unix, codeigniter from localhost.
I'd like to run a controllers via a command-line (CLI). Consequently I'm following this CodeIgniter tutorial and the example works fine.
However when I use it with functions which need to connect to the database, then it appears the following error in the command-line.
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 347
The strange thing is when I access to the same function via URL it works. How that's possible?
Note: The function I pretend to introduce in the command-line is to update the database (it doesn't print anything).
EDIT: I'm getting closer. I've changed the hostname from 'localhost' to '127.0.0.1' and it works. Why?