本文整理匯總了PHP中DatabaseManager::getQuery方法的典型用法代碼示例。如果您正苦於以下問題:PHP DatabaseManager::getQuery方法的具體用法?PHP DatabaseManager::getQuery怎麽用?PHP DatabaseManager::getQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DatabaseManager
的用法示例。
在下文中一共展示了DatabaseManager::getQuery方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isAdministrator
static function isAdministrator()
{
$login = sqlite_escape_string(LoginManager::getLogin());
$results = DatabaseManager::getQuery("SELECT * FROM users WHERE openid='{$login}';");
$user = $results->fetchArray();
return $user && $user['admin'] == 1;
}
示例2: generateContent
function generateContent()
{
$content = '
<h1>' . _('Exercises list') . '</h1>
';
$results = DatabaseManager::getQuery("SELECT * FROM exercises ");
$content .= '<table>
<thead>
<th>' . _('Name') . '</th>
<th>' . _('Description') . '</th>
<th>' . _('Language') . '</th>
<th>' . _('Word count') . '</th>
<th>' . _('Action') . '</th>
</thead>
<tbody>
';
while ($result = $results->fetchArray()) {
$content .= '<tr>';
$content .= '<td>' . $result['name'] . '</td>';
$content .= '<td>' . $result['description'] . '</td>';
$content .= '<td>' . $result['language'] . '</td>';
$content .= '<td>' . $result['word_count'] . '</td>';
$content .= '<td>
<a href="' . RessourceManager::getInnerUrl('exercises/show') . '?id=' . $result['id'] . '">' . _('Details') . '</a><br/>
<a href="' . $result['file'] . '">' . _('Download') . '</a>
</td>';
$content .= '</tr>';
}
$content .= '<tbody></table>';
return $content;
}
示例3: displayContent
function displayContent()
{
$content = '';
$content .= '
<h2>' . _('Administrators') . '</h2>';
$results = DatabaseManager::getQuery("SELECT * FROM users WHERE admin=1 ");
$content .= '<table>
<thead>
<th>' . _('OpenID') . '</th>
<th>' . _('Name') . '</th>
<th>' . _('Email') . '</th>
<th>' . _('Admin rights') . '</th>
<th>' . _('Delete') . '</th>
</thead>
<tbody>
';
while ($result = $results->fetchArray()) {
$content .= '<tr>';
$content .= '<td>' . $result['openid'] . '</td>';
$content .= '<td>' . $result['name'] . '</td>';
$content .= '<td>' . $result['email'] . '</td>';
$content .= '<td><a href="' . RessourceManager::getInnerUrl('admin/user_list') . '?remove_rights=' . $result['openid'] . '">' . _('Remove') . '</a></td>';
$content .= '<td><a href="' . RessourceManager::getInnerUrl('admin/user_list') . '?delete=' . $result['openid'] . '">' . _('Delete') . '</a></td>';
$content .= '</tr>';
}
$content .= '<tbody></table>';
$content .= '
<h2>' . _('Users') . '</h2>';
$results = DatabaseManager::getQuery("SELECT * FROM users WHERE admin=0 ");
$content .= '<table>
<thead>
<th>' . _('OpenID') . '</th>
<th>' . _('Name') . '</th>
<th>' . _('Email') . '</th>
<th>' . _('Admin rights') . '</th>
<th>' . _('Delete') . '</th>
</thead>
<tbody>
';
while ($result = $results->fetchArray()) {
$content .= '<tr>';
$content .= '<td>' . $result['openid'] . '</td>';
$content .= '<td>' . $result['name'] . '</td>';
$content .= '<td>' . $result['email'] . '</td>';
$content .= '<td><a href="' . RessourceManager::getInnerUrl('admin/user_list') . '?add_rights=' . $result['openid'] . '">' . _('Add') . '</a></td>';
$content .= '<td><a href="' . RessourceManager::getInnerUrl('admin/user_list') . '?delete=' . $result['openid'] . '">' . _('Delete') . '</a></td>';
$content .= '</tr>';
}
$content .= '<tbody></table>';
return $content;
}
示例4: displayContent
function displayContent()
{
$content = '';
$content .= '
<h2>' . _('Current propositions') . '</h2>';
$user = LoginManager::getLogin();
$results = DatabaseManager::getQuery("SELECT * FROM proposed_exercises WHERE (state='waiting' OR state='processing')");
while ($result = $results->fetchArray()) {
$content .= '<div class="subblock" ><ul>';
$content .= '<li>' . _('Name: ') . $result['name'] . '</li>';
$content .= '<li>' . _('Description: ') . $result['description'] . '</li>';
$content .= '<li>' . _('Links: ') . $result['links'] . '</li>';
$content .= '<li>' . _('Proposer: ') . $result['user'] . '</li>';
$state = $result['state'];
$stateStr = _('Unknown state');
if ($state == 'waiting') {
$stateStr = _('Waiting for processing');
} elseif ($state == 'processing') {
$stateStr = _('Processing');
} elseif ($state == 'accepted') {
$stateStr = _('Accepted');
}
$content .= '<li>' . _('State: ') . $stateStr . '</li>';
$content .= '</ul></div>';
}
$content .= '
<h2>' . _('Old propositions') . '</h2>';
$results = DatabaseManager::getQuery("SELECT * FROM proposed_exercises WHERE not (state='waiting' OR state='processing')");
while ($result = $results->fetchArray()) {
$content .= '<div class="subblock" ><ul>';
$content .= '<li>' . _('Name: ') . $result['name'] . '</li>';
$content .= '<li>' . _('Description: ') . $result['description'] . '</li>';
$content .= '<li>' . _('Links: ') . $result['links'] . '</li>';
$content .= '<li>' . _('Proposer: ') . $result['user'] . '</li>';
$state = $result['state'];
$stateStr = _('Unknown state');
if ($state == 'waiting') {
$stateStr = _('Waiting for processing');
} elseif ($state == 'processing') {
$stateStr = _('Processing');
} elseif ($state == 'accepted') {
$stateStr = _('Accepted');
}
$content .= '<li>' . _('State: ') . $stateStr . '</li>';
$content .= '</ul></div>';
}
return $content;
}