Welcome Guest, Not a member yet? Register   Sign In
Are database configuration options in database.php available to code?
#1

[eluser]markowe[/eluser]
What I need is to run a MySQL from the shell rather than in PHP so I can dump to a file without breaking PHP memory limits. So I am doing this:

Code:
$shellCommand = "mysql --user=XXXXX --password=XXXXX --database=XXXXXX --execute='" . $sql . "' > '". $catFileLocalPath . $catDumpFileName . "'";

Disregard the command itself, that's fine, what I want to know is are my database user and password settings available programmatically? I want to insert them into the string here, rather than hard-coding them which would be sloppy. I can't seem to find anything to this effect in the user guide, and it would make sense NOT to make them available for security reasons, of course, but I thought I'd ask...

Thanks,

Mark
#2

[eluser]Sbioko[/eluser]
Yes, they are available in the code. Coder can just include database.php file and read settings.
#3

[eluser]markowe[/eluser]
[quote author="Sbioko" date="1264973942"]Yes, they are available in the code. Coder can just include database.php file and read settings.[/quote]

Now there's an idea Smile Thanks, I never thought of that - I guess I was trying to work within the framework, but this would probably be simplest.
#4

[eluser]Boris Strahija[/eluser]
I found this to work the best:
http://www.creolab.hr/2009/11/integratio...deigniter/
#5

[eluser]markowe[/eluser]
[quote author="Boris Strahija" date="1265040844"]I found this to work the best:
http://www.creolab.hr/2009/11/integratio...deigniter/[/quote]

Thanks, so a straight "include" is unavoidable? I'd never heard of RedBean either - wish I had found that when I was creating my own database variable storage class, RedBean is much more advanced!
#6

[eluser]Boris Strahija[/eluser]
I really didn't do much investigating, this just worked, and I didn's seem like a big performance hit. Maybe there is a better way, you can wait if someone posts it Wink
#7

[eluser]markowe[/eluser]
[quote author="Boris Strahija" date="1265045118"]I really didn't do much investigating, this just worked, and I didn's seem like a big performance hit. Maybe there is a better way, you can wait if someone posts it Wink[/quote]

Oh, it wasn't performance I was worried about, just staying within the Codeigniter framework. Obviously if there was a $this->db->setting('username') object, then I would prefer to use that.

Thanks and bok!

MD
#8

[eluser]Boris Strahija[/eluser]
There is the config class, but I think that the database.php config file is not a valid config file Wink
So including is the only sollution as far as I know.
#9

[eluser]markowe[/eluser]
[quote author="Boris Strahija" date="1265049985"]There is the config class, but I think that the database.php config file is not a valid config file Wink
So including is the only sollution as far as I know.[/quote]

Thanks, I guess I'll do that - I am going outside the framework to execute shell scripts anyway, so I guess it's no big deal!




Theme © iAndrew 2016 - Forum software by © MyBB