I'm very new to PHP, and I'm trying to add features to an already existing app.
The following PHP code will be used each time there's a database request from the client side.
<?php
header("Access-Control-Allow-Origin: *");
require_once("config/keychain.php");
function decrypt($data, $key, $iv){
$key = pack('H*', $key);
$iv = pack('H*', $iv);
return mcrypt_decrypt( MCRYPT_RIJNDAEL_128 , $key , $data ,
MCRYPT_MODE_CBC , $iv );
}
$request = (object)$_REQUEST;
$dbConfig = (object)parse_ini_string(decrypt(file_get_contents("config/database.ini"), ENCRYPTION_KEY, ENCRYPTION_IV));
require_once("include/UniversalDB.php");
require_once("include/UniversalModel.php");
require_once("include/UniversalController.php");
//
// Set DB Connection
//
$dbConnection = new UniversalDB();
$dbConnection->init($dbConfig->host, $dbConfig->user, $dbConfig-
>password, 2);
//$universalDB->connect();
require_once("boot.php");
?>
I'm trying to maintain one property from one of these requests values(the login $_REQUEST values).
I tried adding this to the previous script.
if(property_exists($request,'selectedDatabase')){
$selectedDatabase = $request->selectedDatabase;
}
I will get the $selectedDatabase initialized correctly. However, every time this script is running everything gets uninitialized.
I also tried making $selectedDatabase in $GLOBALS and making it static,but I lose the value when another request is coming.
Any ideas how can I maintain $selectedDatabase?
NOTE: The file where this script is written called "Index.php", and I'm not sure if it's the first script to load or not. However it seems like it!
Thank you,
Aucun commentaire:
Enregistrer un commentaire