Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

License database

posted by frank 8 years ago

Hello all,

My problem :

What i'm trying to do is the following. Two databases, 1 gets the information of the other. So in my first database i want to make sure some company still has an valid license record.

If there is an valid record in the first database it will return a record with the database credentials of the production database of this company. The databases aren't on the same server for security reasons.

Normally you can create two databases with this awesome lib like this :
$db_license = new fDatabase('mysql', $dbname, $dbuser, $dbpass, $dbhost, $dbport);
$db_production = new fDatabase('mysql', $dbname2, $dbuser2, $dbpass2, $dbhost2, $dbport2);

// Attach the db_production db as the default
fORMDatabase::attach($db_production);
fORMDatabase::attach($db_license, 'db_license');

But how can i make this work as described earlier? By using the db_license db the fill the database credentials of the other?

With kind regards,

Frank van der Geld Uni-Coder BV

Here is the general concept:

$license_db      = new fDatabase('mysql', $dbname, $dbuser, $dbpass, $dbhost, $dbport);
$company_license = $license_db->query("SELECT * FROM licenses WHERE company_name = %s", $company_name)->fetchRow();
$real_db         = new fDatabase('mysql', $company_license['db'], $company_license['user'], $company_license['password'], $company_license['host'], $company_license['port']);
fORMDatabase::attach($real_db);
posted by wbond 8 years ago

Thanx for your fast answer.
The problem still remains because the company_name determines wich record to fetch.
But this value isn't available untill the user is logging in :

And untill this point no database action is needed. In the config.php I well set the login page :
fAuthorization::setLoginPage(SITE_URL .'login.php');

My login screen uses the following values :

company: company_name
username: Frank
password: something

So i wanted to use the value company_name of the login form to attach the final production database for this company. Else it won't be a generic approach to the license database and i will still have to hardcode the company_name value in the init!?.

Is this even possible? To make the a ORM attachment of the fDatabase object after i know the login values?

With kind regards,
Frank

posted by frank 8 years ago