本文整理匯總了PHP中models\User::setDefaultDatabase方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::setDefaultDatabase方法的具體用法?PHP User::setDefaultDatabase怎麽用?PHP User::setDefaultDatabase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::setDefaultDatabase方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: readDbFromRequest
/**
* Read the user belonging to the incoming request and get his/her defaultDB.
*
* @return String $userdb
*/
public static function readDbFromRequest()
{
$app = \Slim\Slim::getInstance();
$oUser = new User();
$request = $app->request();
$public_key = $request->headers('X-PublicKey');
//get User array from sent public key
$user = $oUser->getUserByPublicKey($public_key);
$userdb = $oUser->setDefaultDatabase($user['LoginID']);
if ($userdb != NULL) {
return $userdb;
} else {
$response["error"] = true;
$response["defaultdb"] = "Could not select database of user.";
LogHelper::write("Could not select database, check if the user's DefaultDB is available.", $user['username']);
RequestHelper::echoResponse(500, $response);
$app->stop();
}
}
示例2: function
use lib\LogHelper as Log;
// API Versioning
$app->group('/v1', function () use($app) {
/**
* GET route to export whole database to JSON
*
*/
$app->get('/database/export', function () use($app) {
//create empty user
$oUser = new User();
//request header
$request = $app->request();
$public_key = $request->headers('X-PublicKey');
//get User array from sent public key
$user = $oUser->getUserByPublicKey($public_key);
$userdb = $oUser->setDefaultDatabase($user['LoginID']);
//get access level string of user
$access_level = $oUser->getAccessLevel($user['LoginID']);
//create new instance with the user specific database
$tempTool = new DbExport($userdb);
//read relevant table names with the user specific access level
$export = $tempTool->readRelevantTables($access_level);
$app->contentType('application/json;charset=utf-8');
echo json_encode($export);
});
/**
* GET route to export database meta information to JSON
*
*/
$app->get('/database/scheme', function () use($app) {
$userdb = R::readDbFromRequest();