Page 1 of 1

Editing config file

Posted: Mon Dec 03, 2012 8:13 am
by Sdesigns
Hi,

My confi file is locate at

application/config/database.php

and looks like

Code: Select all

$db['default']['username'] = "user_username";
$db['default']['password'] = "password";
$db['default']['database'] = "user_dbname";


Can someone please tell me what I need to do to get the installer to insert the correct database info into the necessary fields. I have tried just about everything and just cannot get it to work :(

Thanks

Re: Editing config file

Posted: Mon Dec 03, 2012 11:16 am
by Phil
Hello,

You could do something like this:

Code: Select all

$this->sr("application/config/database.php",array(
'#"user_username"#' => $this->preg_var_export($this->db_user),
'#"password"#' => $this->preg_var_export($this->db_pass),
'#"user_dbname"#' => $this->preg_var_export($this->db_name),
));


Thank you,
Phil

Re: Editing config file

Posted: Mon Dec 03, 2012 12:24 pm
by Sdesigns
Hi Phil,

The code you posted almost works :)

It removed the old values but is not writing new ones, so I end up with

Code: Select all

$db['default']['username'] = "";
$db['default']['password'] = "";
$db['default']['database'] = "";

Re: Editing config file

Posted: Mon Dec 03, 2012 12:31 pm
by Phil
Hello,

In the XML is the "database" requirement should be set to "1" for those values to be populated. Is that set correctly?

Thank you,
Phil

Re: Editing config file

Posted: Mon Dec 03, 2012 12:55 pm
by Sdesigns
Hi,

The database is being populated now, but not the config file.

There is no such value in my XML file, this is all I have in it.

Code: Select all

<installer>
   <id>project name</id>
   <build>9</build>
   <url>http://path/to/file.tar.gz</url>
   <md5>7836b8e58db87eb2817125dfffe82d42</md5>
</installer>

Re: Editing config file

Posted: Mon Dec 03, 2012 2:40 pm
by Sdesigns
Hi,
I just found the DB line in the GUI.

Yes it is set to "1"

Code: Select all

<requirement id="database" value="1"/>


Any other ideas why installatron would be removing the old values but not writing the new ones?

Re: Editing config file

Posted: Mon Dec 03, 2012 8:10 pm
by Josh
Greetings,

As long as "database" is set in the XML this should be working. Note that the XML is cached and only updated when file timestamps change, so make sure you're seeing the "Database" section when installing the app. If you aren't seeing it, try deleting the /var/installatron/installers/APPID/ directory from your server and recopying the app package files.

Best regards,
Josh

Re: Editing config file

Posted: Tue Dec 04, 2012 5:04 am
by Sdesigns
Hi,

I am seeing the database section during installation.
Here is what is currently happening.

Archive is extracted correctly
Database is added correctly
Database is populated from .sql file correctly
Application Admin user/pass are imported into database correctly
config file is edited (old values removed but no new values inserted)

Currently my step 3 of installation looks like this

Code: Select all

//==========================================================================
// STEP III: CONFIGURING INSTALL
//==========================================================================
   
public function step3_init()
{
   $this->setStepLabel("_step_progress_processing");
}
   
public function step3_process()
{
{
   
   $this->db_import("install/assets/install.sql");
$this->sr("application/config/database.php",array(
'#"user_username"#' => var_export($this->db_user,true),
'#"password"#' => var_export($this->db_pass,true),
'#"user_dbname"#' => var_export($this->db_name,true),
));
}
}

Re: Editing config file

Posted: Tue Dec 04, 2012 6:59 am
by Sdesigns
OK, I got it working.
I made a new config file which edited just fine, and then move it to the required directory.
Still unsure why it would not edit the original file though, but at least it is working.