本文整理汇总了PHP中Database::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::query方法的具体用法?PHP Database::query怎么用?PHP Database::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: migrateFromLegacy
/**
* Migrate form legacy column set editor.
*
* @return void
*/
private function migrateFromLegacy()
{
if (!$this->database->fieldExists('bootstrap_grid', 'tl_content') && $this->database->fieldExists('columnset_id', 'tl_content')) {
$this->database->query('ALTER TABLE tl_content ADD bootstrap_grid int(10) unsigned NOT NULL default \'0\';');
$this->database->query('UPDATE tl_content SET bootstrap_grid=columnset_id WHERE bootstrap_grid = 0');
}
}
示例2: lists
/**
* 重载lists
* 加百分比统计功能
*/
public function lists($query_struct = array())
{
$list = parent::lists($query_struct);
$agent_detail_num = array();
$version_num = array();
$type_num = array();
$total_num = $this->count(array());
$db = new Database();
//统计agent_detail数目
$sql = "SELECT agent_detail, count(id) as agent_num FROM kc_browser_stats WHERE 1=1 GROUP BY agent_detail";
$query = $db->query($sql);
foreach ($query as $key => $_query) {
$agent_detail_num[$_query->agent_detail] = $_query->agent_num;
}
//统计version数目
$sql = "SELECT version, count(id) as version_num FROM kc_browser_stats WHERE 1=1 GROUP BY version";
$query = $db->query($sql);
foreach ($query as $key => $_query) {
$version_num[$_query->version] = $_query->version_num;
}
//统计type数目
$sql = "SELECT type, count(id) as type_num FROM kc_browser_stats WHERE 1=1 GROUP BY type";
$query = $db->query($sql);
foreach ($query as $key => $_query) {
$type_num[$_query->type] = $_query->type_num;
}
//计算百分比
foreach ($list as $key_list => $_list) {
$list[$key_list]['agent_detail_percentage'] = round($agent_detail_num[$_list['agent_detail']] / $total_num * 100);
$list[$key_list]['version_percentage'] = round($version_num[$_list['version']] / $total_num * 100);
$list[$key_list]['type_percentage'] = round($type_num[$_list['type']] / $total_num * 100);
}
return $list;
}
示例3: save
function save(Entity $entity)
{
$vars = get_object_vars($entity);
//print_r($vars);
if ($vars['id'] == 0) {
$vars['id'] == 'NULL';
}
$cols = array();
$values = array();
$updates = array();
foreach ($vars as $key => $value) {
$cols[] = "`{$key}`";
$values[] = ' :' . $key . ' ';
$updates[] = " `{$key}` = VALUES(`{$key}`) ";
}
$col = implode(",", $cols);
$value = implode(",", $values);
$update = implode(",", $updates);
$sql = "INSERT INTO {$this->tableName()} ({$col}) VALUES ({$value}) ON DUPLICATE KEY UPDATE {$update}";
$res = $this->db->query($sql, $vars);
if ($res === FALSE) {
return FALSE;
}
if ($entity->id == 0) {
$entity->id = $this->db->lastInsertId();
}
return $entity;
}
示例4: checkLogin
function checkLogin($login, $pass)
{
$db = new Database();
//Traigo el usuario
$q = "select salt from jugador where login='{$login}' limit 1";
$r = $db->query($q);
//Controlo que exista el usuario con el login $login
if ($db->num_rows($r) > 0) {
//Traigo el registro
$data = $db->fetch_array($r);
$salt_db = $data['salt'];
//Genero el mismo hash que se creo al registrar jugador
$hashedpass = hash('sha512', $pass . $salt_db);
$q2 = "select * from jugador where login='{$login}' and pass=PASSWORD('{$hashedpass}')";
$r2 = $db->query($q2);
if ($db->num_rows($r2) > 0) {
return 1;
} else {
return 0;
}
} else {
alertMessage('El usuario no existe');
exit;
}
$db->close();
}
示例5: saveLayerRelations
/**
* Save layer relations.
*
* @param mixed $layerId The layer id values.
* @param \DataContainer $dataContainer The dataContainer driver.
*
* @return null
*/
public function saveLayerRelations($layerId, $dataContainer)
{
$new = deserialize($layerId, true);
$values = array();
$result = $this->database->prepare('SELECT * FROM tl_leaflet_map_layer WHERE mid=? order BY sorting')->execute($dataContainer->id);
while ($result->next()) {
$values[$result->lid] = $result->row();
}
$sorting = 0;
foreach ($new as $layerId) {
if (!isset($values[$layerId])) {
$this->database->prepare('INSERT INTO tl_leaflet_map_layer %s')->set(array('tstamp' => time(), 'lid' => $layerId, 'mid' => $dataContainer->id, 'sorting' => $sorting))->execute();
$sorting += 128;
} else {
if ($values[$layerId]['sorting'] <= $sorting - 128 || $values[$layerId]['sorting'] >= $sorting + 128) {
$this->database->prepare('UPDATE tl_leaflet_map_layer %s WHERE id=?')->set(array('tstamp' => time(), 'sorting' => $sorting))->execute($values[$layerId]['id']);
}
$sorting += 128;
unset($values[$layerId]);
}
}
$ids = array_map(function ($item) {
return $item['id'];
}, $values);
if ($ids) {
$this->database->query('DELETE FROM tl_leaflet_map_layer WHERE id IN(' . implode(',', $ids) . ')');
}
return null;
}
示例6: RenderPage
public function RenderPage()
{
require_once "/Classes/databaseHandler.class.php";
$Database = new Database();
print '
<title>Run2Day - Bannerbeheer</title>
<h1>Bannerbeheer</h1>
<table class="table">
<tr>
<th>Toegevoegd aan</th>
<th>Bestandsnaam</th>
<th>Banner tekst</th>
<th>Verwijderen</th>
</tr> ';
$Database->query('SELECT ID, fileName, fk_wedstrijdID, text FROM afbeeldingen');
$result = $Database->resultset();
foreach ($result as $key) {
$Database->query('SELECT name FROM wedstrijden WHERE wedstrijdID=?');
$Database->bind(1, $key['fk_wedstrijdID']);
$wedstrijd = $Database->single();
print '<tr><td>' . $wedstrijd['name'] . ' </td>';
print '<td>' . $key['fileName'] . ' </td>';
print '<td>' . $key['text'] . ' </td>';
print ' <td><a class="fa fa-trash-o" href="?dashboard&deletebanner=' . $key['ID'] . '"</td></tr>';
}
print '
</table>
<div class="col-md-4">
<h3>Banner afbeelding toevoegen</h3>
<form action="../Classes/submitWedstrijd.php" method="POST" enctype="multipart/form-data">
<label for="usr">Banner toevoegen aan:</label>
<select class="form-control" name="wedstrijd" id="wedstrijd">';
$Database->query('SELECT name, wedstrijdID FROM wedstrijden');
$result = $Database->resultset();
foreach ($result as $key) {
print ' <option> ' . $key['name'] . '</option>';
}
print '
</select>
<div class="form-group">
<label for="usr">Banner tekst:</label>
<input type="text" class="form-control" id="name" name="name" required>
</div>
<div class="form-group">
<label for="usr">Afbeelding:</label>
<input type="file" name="file" id="file">
</div>
<input type="submit" value="Opslaan">
<br><br>
</form>
</div>
</div>
</div> ';
}
示例7:
/**
* Selects the user information for $userId
* @param int $userId
* @return Resultset $q
*/
function _selectUser($userId)
{
$sql = "SELECT USER_ID, USER_NAME, USER_PASSWORD, \r\n\t\t\tUSER_ACCESSLEVEL, USER_COLOR, USER_IMG\r\n\t\t\tFROM TBL_USER \r\n\t\t\tWHERE USER_ID = ??";
$q = $this->db->query($sql);
$q->bind_values(array($userId));
$q->execute();
return $q;
}
示例8: getChoicesByQuestion
function getChoicesByQuestion($question_id)
{
$db = new Database();
$db->query('SELECT * FROM choices WHERE question_id = :question_id');
$db->query(':question_id', $question_id);
// Assign Rows
$rows = $db->resultset();
return $rows;
}
示例9: checkSystem
function checkSystem($memberid)
{
$database = new Database();
$othernotes = $database->query('SELECT notification, label, timestamp, color, fk_from_id, isRead FROM s_notifications_log LEFT JOIN s_notifications_labels ON s_notifications_log.fk_label_id = s_notifications_labels.id WHERE fk_member_id=' . $memberid . ' ORDER BY timestamp DESC LIMIT 3');
$systemnotes = $database->query('SELECT notification, label, timestamp, color FROM s_notifications LEFT JOIN s_notifications_labels ON s_notifications.fk_label_id = s_notifications_labels.id WHERE isVisible=1 ORDER BY timestamp DESC');
//.' AND isRead=0'
$notes = array("others" => $othernotes, "system" => $systemnotes);
return $notes;
}
示例10: mainP
public function mainP()
{
$sen = 0;
$db = new Database();
foreach ($this->sentences as $sentence) {
$highest = 0;
$words = array();
$words = explode(" ", $sentence);
foreach ($words as $word) {
if (!in_array(strtolower($word), $this->stopwords)) {
//Fetching the meaning definition of the senses From the WordNet
$db->query("SELECT * from words where lemma like :word");
$db->bind("word", $word);
$wordid = $db->single()->wordid;
$db->query("SELECT * from senses where wordid like :wordid");
$db->bind("wordid", $wordid);
$resulta2 = $db->resultset();
foreach ($resulta2 as $row) {
$synsetid = $row->synsetid;
$sample2[] = $synsetid;
$title = $row->wordid . " " . $row->senseid;
}
$db->query("select * from synsets where synsetid like :sample");
$db->bind("sample", $sample2[0]);
$resulta3 = $db->resultset();
unset($sample2[0]);
for ($i = 0; $i < count($sample2) + 1; $i++) {
${result_A . $i} = $sample2[$i];
${lexdomains_var . $i} = $lexdomains[$i];
$db->query("select * from synsets where synsetid like :sample");
$db->bind("sample", ${result_A . $i});
${result . $i} = $db->resultset();
foreach (${result . $i} as $row) {
${pos . $i} = $row->pos;
if (${pos . $i} == "s") {
${pos . $i} = "satellite adj";
}
$def = $row->definition;
$def = preg_replace('/[^a-zA-Z0-9_ -]/s', '', $def);
$definition = array();
$definition = explode(" ", $def);
$frequency = $this->frequency($definition);
if ($frequency > $highest) {
$highest = $frequency;
}
}
}
$sample2 = array();
}
}
$this->frequencies[] = $highest;
$this->sentence_count[] = $sen;
$sen++;
}
}
示例11: index
/**
* Displays a list of reports
* @param boolean $category_id If category_id is supplied filter by
* that category
*/
public function index($category_id = false)
{
$this->template->content = new View('mobile/reports');
$get_params = "?";
if(isset($_GET['c']) AND !empty($_GET['c']) AND $_GET['c']!=0)$get_params .= "c=".$_GET['c']."&";
if(isset($_GET['sw']))$get_params .= "sw=".$_GET['sw']."&";
if(isset($_GET['ne']))$get_params .= "ne=".$_GET['ne']."&";
if(isset($_GET['l']) AND !empty($_GET['l']) AND $_GET['l']!=0)$get_params .= "l=".$_GET['l'];
$get_params = rtrim(rtrim($get_params,'&'),'?');
$this->template->content->get_params = $get_params;
$db = new Database;
$filter = ( $category_id )
? " AND ( c.id='".$category_id."' OR
c.parent_id='".$category_id."' ) "
: " AND 1 = 1";
// 検索キーワード取得
if(isset($_GET["keyword"]) && trim($_GET["keyword"]) !==""){
$keywords = array();
$keyword = str_replace(" "," ",$_GET["keyword"]);
$keywords = explode(" ",$keyword);
}
$keyword_like = "1=1";
if(isset($keywords) && count($keywords)){
$keyword_like = "";
foreach($keywords as $val){
$keyword_like .= "(incident_title like '%".addslashes($val)."%' OR incident_description like '%".addslashes($val)."%') AND ";
}
$keyword_like = rtrim($keyword_like," AND ");
}
// Pagination
$pagination = new Pagination(array(
'style' => 'mobile',
'query_string' => 'page',
'items_per_page' => (int) Kohana::config('mobile.items_per_page'),
'total_items' => $db->query("SELECT DISTINCT i.* FROM `".$this->table_prefix."incident` AS i JOIN `".$this->table_prefix."incident_category` AS ic ON (i.`id` = ic.`incident_id`) JOIN `".$this->table_prefix."category` AS c ON (c.`id` = ic.`category_id`) WHERE `incident_active` = '1' AND $keyword_like $filter")->count()
));
$this->template->content->pagination = $pagination;
$incidents = $db->query("SELECT DISTINCT i.*, l.location_name FROM `".$this->table_prefix."incident` AS i JOIN `".$this->table_prefix."incident_category` AS ic ON (i.`id` = ic.`incident_id`) JOIN `".$this->table_prefix."category` AS c ON (c.`id` = ic.`category_id`) JOIN `".$this->table_prefix."location` AS l ON (i.`location_id` = l.`id`) WHERE `incident_active` = '1' AND $keyword_like $filter ORDER BY incident_date DESC LIMIT ". (int) Kohana::config('mobile.items_per_page') . " OFFSET ".$pagination->sql_offset);
// If Category Exists
if ($category_id)
{
$category = ORM::factory("category", $category_id);
}
else
{
$category = FALSE;
}
$this->template->content->incidents = $incidents;
$this->template->content->category = $category;
}
示例12: renderSearch
public function renderSearch()
{
require_once "/Classes/databaseHandler.class.php";
$Database = new Database();
$Database->query('SELECT fileName, name, date FROM wedstrijden');
$resultSet = $Database->single();
print '
</div >
<div id = "clickTable" class="container" >
<table id = "myTable" class="table" >
<thead>
<tr>
<th> Startnr <i class="fa fa-sort" ></i></th>
<th> Wedstrijd <i class="fa fa-sort" ></i></th>
<th> Naam <i class="fa fa-sort" ></i></th>
<th> Woonplaats <i class="fa fa-sort" ></i></th>
<th> Geboortedatum <i class="fa fa-sort" ></i></th>
<th> Geslacht</th >
<th> Netto tijd <i class="fa fa-sort" ></i></th>
<th> Onderdeel <i class="fa fa-sort" ></i> </th>
<th> Beeld</th>
</tr></thead ><tbody> ';
$Database->query('SELECT * FROM tijden WHERE Naam LIKE ?');
if (!isset($_GET['show'])) {
$Database->bind(1, "%" . $_POST['naam'] . "%");
$result = $Database->resultset();
if (empty($result)) {
echo "Deelnemer niet gevonden.";
}
foreach ($result as $data) {
$Database->query('SELECT fileName, name, date FROM wedstrijden WHERE wedstrijdID=?');
$Database->bind(1, $data['fk_wedstrijdID']);
$resultSet = $Database->single();
print ' <tr><td> ' . $data['Startnummer'] . ' </td> ';
print '<td> ' . $resultSet['name'] . ' </td> ';
print '<td> ' . $data['Naam'] . ' </td> ';
print '<td> ' . $data['Woonplaats'] . ' </td> ';
print '<td> ' . $data['Geboortedatum'] . ' </td> ';
echo "<td>";
if ($data['Geslacht'] == "V") {
echo ' <i class="fa fa-female" ></i> ';
} else {
echo '<i class="fa fa-male" ></i> ';
}
echo "</td>";
print '<td> ' . $data['NettoTijd'] . ' </td> ';
print '<td> ' . $data['Onderdeel'] . ' </td> ';
print "<td><a class='fa fa-line-chart' href='?statistieken&startnummer=" . $data['Startnummer'] . "&eventid=" . $data['fk_wedstrijdID'] . "'></a>";
print " <a class='fa fa-video-camera' href='?newplayer&wedstrijd=" . $resultSet['name'] . "&naam=& startnummer=" . $data['Startnummer'] . "'></a>";
print " <a class='fa fa-camera' </a> ";
print " <a class='fa fa-certificate' target='_blank' href='https://uitslagensoftware.nl/certificaat_3.php?event_id=2015083000294&S= " . $data['Startnummer'] . "'></a></td></tr>";
}
}
}
示例13: page
public function page($pagenum)
{
css::add(array('media/css/rating.css'));
$this->template->content = new View('content/rating');
$db = new Database();
$query = $db->query("SELECT Company FROM ambestf");
$this->pagination = new Pagination(array('directory' => 'pagination', 'style' => 'trinhall', 'uri_segment' => 3, 'query_string' => '', 'items_per_page' => 23, 'auto_hide' => FALSE, 'total_items' => $query->count()));
$this->pagination->extras = array('hide_count' => TRUE);
$b = $this->pagination->items_per_page;
$offset = ($pagenum - 1) * $b;
$result = $db->query("SELECT Company, Rating1, Rating2, Rating3, Rating4 FROM ambestf ORDER BY Company ASC LIMIT {$b} OFFSET {$offset}");
$this->template->content->result = $result;
}
示例14: userPostCount
function userPostCount($user_id)
{
$db = new Database();
$db->query("SELECT * FROM topics \n\t\t\t\t\t WHERE user_id=:user_id");
$db->bind('user_id', $user_id);
$db->resultSet();
$topic_count = $db->rowCount();
$db->query("SELECT * FROM replies\n\t\t\t\t WHERE user_id=:user_id");
$db->bind('user_id', $user_id);
$db->resultSet();
$reply_count = $db->rowCount();
return $topic_count + $reply_count;
}
示例15: page
public function page($pagenum)
{
css::add(array('media/css/fee.css'));
javascript::add(array('media/js/ext-base.js', 'media/js/ext-all.js', 'media/js/app.js'));
$this->template->content = new View('content/fees');
$db = new Database('fees');
$query = $db->query("SELECT co_name FROM feesNew");
$this->pagination = new Pagination(array('uri_segment' => 'page', 'total_items' => $query->count(), 'items_per_page' => 28, 'style' => 'punbb'));
$b = $this->pagination->items_per_page;
$offset = ($pagenum - 1) * $b;
$result = $db->query("SELECT co_name FROM feesNew ORDER BY co_name ASC LIMIT {$b} OFFSET {$offset}");
$this->template->content->result = $result;
}