/** * Upgrades for MajorVersion = 0, MinorVersion = 0 * * Add code to perform actual database updgrad operation * For first version, create supporting tables * * @param $dbhandle handle to database * @return $status true if operation was successful */ function V_Major0_Minor0_Upgrade($dbhandle) { $logger = LoggerSingleton::GetInstance(); $logger->LogInfo("V0_0_Upgrade - Enter "); $status = true; /* create password table if not persent */ // check if existing if (true == $status) { $status = IsExisting_Password($dbhandle); $logger->LogInfo("IsExisting Password table status :" . var_export($status, true)); } // Create table if (false == $status) { $status = CreateTable_Password($dbhandle); $logger->LogInfo("Create Password table status : " . var_export($status, true)); } /* Create UserDetails table if not present */ if (true == $status) { $status = IsExisting_UserDetails($dbhandle); $logger->LogInfo("IsExisting UserDetails table status :" . var_export($status, true)); } // Create table if (false == $status) { $status = CreateTable_UserDetails($dbhandle); $logger->LogInfo("Create UserDetails table status : " . var_export($status, true)); } /* Create TodoList table if not present already */ if (true == $status) { $status = IsExisting_TodoList($dbhandle); $logger->LogInfo("IsExisting TodoList table status :" . var_export($status, true)); } // Create table if (false == $status) { $status = CreateTable_TodoList($dbhandle); $logger->LogInfo("Create TodoList table status : " . var_export($status, true)); } $logger->LogInfo("Exit form V_Major0_Minor0_Upgrade with status :" . var_export($status, true)); return $status; }
global $PasswordTable_User; $status = true; // get handle $dbhandle = new mysqli($dbhostname, $username, $password, $dbname); if (false == $dbhandle) { $status = false; $logger->LogError("Unable to connect to database : {$dbhandle->error}"); } // check if existing if (true == $status) { $status = IsExisting_Password($dbhandle); $logger->LogInfo("IsExisting Password table status :" . var_export($status, true)); } // Create table if (false == $status) { $status = CreateTable_Password($dbhandle); $logger->LogInfo("Create Password table status : " . var_export($status, true)); } // insert into table $user = '******'; $password = '******'; $id = null; if (true == $status) { $status = InsertInto_Password($dbhandle, $id, $user, $password); $logger->LogInfo("Insert into table status : " . var_export($status, true)); } // select and display record if (true == $status) { $status = SelectByIdFrom_Password($dbhandle, $id, $user, $password); $logger->LogInfo("Select into Password table status : " . var_export($status, true)); }