本文整理汇总了PHP中sql_row_keyed函数的典型用法代码示例。如果您正苦于以下问题:PHP sql_row_keyed函数的具体用法?PHP sql_row_keyed怎么用?PHP sql_row_keyed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sql_row_keyed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_position
function create_position($screen_id_in, $feed_id_in, $field_id_in, $weight_in = DEFAULT_WEIGHT){
if($this->set){
return true; //You've already got an object!
} else {
if(!is_numeric($screen_id_in) || !is_numeric($feed_id_in) || !is_numeric($field_id_in) || !is_numeric($weight_in)){
return false;
}
$sql = "SELECT COUNT(id) FROM position WHERE screen_id = $screen_id_in AND feed_id = $feed_id_in AND field_id = $field_id_in";
$res = sql_query($sql);
$data = (sql_row_keyed($res,0));
if( $data['COUNT(id)'] != 0){
return false; //Implying the mapping already exists
} else {
$sql = "INSERT INTO position (screen_id, feed_id, field_id, weight) VALUES ($screen_id_in, $feed_id_in, $field_id_in, $weight_in)";
$res = sql_query($sql);
if($res){
$this->id = sql_insert_id();
$this->screen_id = $screen_id_in;
$this->feed_id = $feed_id_in;
$this->field_id = $field_id_in;
$this->weight = $weight_in;
$this->set = true;
return true;
} else {
return false;
}
}
}
}
示例2: feedAction
function feedAction()
{
$this->feed = new Feed($this->args[1]);
if (!$this->feed->user_priv($_SESSION['user'], 'moderate')) {
$this->flash('You do not have enough privileges to moderate this feed', 'error');
redirect_to(ADMIN_URL . "/moderate");
}
$sql = "SELECT content.id FROM content\n LEFT JOIN feed_content\n ON content.id = feed_content.content_id\n WHERE feed_content.feed_id = {$this->feed->id}\n AND feed_content.moderation_flag IS NULL\n GROUP BY content.id\n ORDER BY content.type_id, content.name;";
$res = sql_query($sql);
for ($i = 0; $row = sql_row_keyed($res, $i); ++$i) {
$this->contents[] = new Content($row['id']);
}
$this->setTitle('Moderating ' . $this->feed->name);
$this->breadcrumb($this->feed->name);
}
示例3: listAction
function listAction()
{
$ids = sql_select('group', 'id');
$this->groups = array();
if (is_array($ids)) {
foreach ($ids as $group) {
$group = new Group($group['id']);
$this->groups[$group->id]['name'] = $group->name;
$members = $group->get_members();
$this->groups[$group->id]['members'] = is_array($members) ? count($members) : 0;
$feeds_res = sql_query('SELECT COUNT(id) as feeds FROM `feed` WHERE `group_id` = ' . $group->id);
$this->groups[$group->id]['controls'] = NULL;
if ($feeds_res) {
$num_feeds = sql_row_keyed($feeds_res, 0);
$num_feeds = $num_feeds['feeds'];
if ($num_feeds == 1) {
$this->groups[$group->id]['controls'][] = "1 feed";
} else {
if ($num_feeds > 1) {
$this->groups[$group->id]['controls'][] = $num_feeds . " feeds";
}
}
}
$screens_res = sql_query('SELECT COUNT(id) as screens FROM `screen` WHERE `group_id` = ' . $group->id);
if ($screens_res) {
$num_screens = sql_row_keyed($screens_res, 0);
$num_screens = $num_screens['screens'];
if ($num_screens == 1) {
$this->groups[$group->id]['controls'][] = "1 screen";
} else {
if ($num_screens > 1) {
$this->groups[$group->id]['controls'][] = $num_screens . " screens";
}
}
}
}
}
}
示例4: create_field_entry_rooms
function create_field_entry_rooms($disabled = FALSE)
{
global $multiroom_allowed, $room_id, $area_id, $selected_rooms, $areas;
global $tbl_room, $tbl_area;
// $selected_rooms will be populated if we've come from a drag selection
if (empty($selected_rooms)) {
$selected_rooms = array($room_id);
}
// Get the details of all the enabled rooms
$all_rooms = array();
$sql = "SELECT R.id, R.room_name, R.area_id\n FROM {$tbl_room} R, {$tbl_area} A\n WHERE R.area_id = A.id\n AND R.disabled=0\n AND A.disabled=0\n ORDER BY R.area_id, R.sort_key";
$res = sql_query($sql);
if ($res === FALSE) {
trigger_error(sql_error(), E_USER_WARNING);
fatal_error(FALSE, get_vocab("fatal_db_error"));
}
for ($i = 0; $row = sql_row_keyed($res, $i); $i++) {
$all_rooms[$row['area_id']][$row['id']] = $row['room_name'];
}
echo "<div id=\"div_rooms\">\n";
echo "<label for=\"rooms\">" . get_vocab("rooms") . ":</label>\n";
echo "<div class=\"group\">\n";
// First of all generate the rooms for this area
$params = array('name' => 'rooms[]', 'id' => 'rooms', 'options' => $all_rooms[$area_id], 'force_assoc' => TRUE, 'value' => $selected_rooms, 'multiple' => $multiroom_allowed, 'mandatory' => $multiroom_allowed, 'disabled' => $disabled, 'attributes' => array('size="5"'));
generate_select($params);
// Then generate templates for all the rooms
$params['disabled'] = TRUE;
$params['create_hidden'] = FALSE;
foreach ($all_rooms as $a => $rooms) {
$attributes = array();
$attributes[] = 'style="display: none"';
// Put in some data about the area for use by the JavaScript
$attributes[] = 'data-enable_periods=' . ($areas[$a]['enable_periods'] ? 1 : 0);
$attributes[] = 'data-default_duration=' . (isset($areas[$a]['default_duration']) && $areas[$a]['default_duration'] != 0 ? $areas[$a]['default_duration'] : SECONDS_PER_HOUR);
$attributes[] = 'data-default_duration_all_day=' . ($areas[$a]['default_duration_all_day'] ? 1 : 0);
$attributes[] = 'data-max_duration_enabled=' . ($areas[$a]['max_duration_enabled'] ? 1 : 0);
$attributes[] = 'data-max_duration_secs=' . $areas[$a]['max_duration_secs'];
$attributes[] = 'data-max_duration_periods=' . $areas[$a]['max_duration_periods'];
$attributes[] = 'data-max_duration_qty=' . $areas[$a]['max_duration_qty'];
$attributes[] = 'data-max_duration_units="' . htmlspecialchars($areas[$a]['max_duration_units']) . '"';
$attributes[] = 'data-timezone="' . htmlspecialchars($areas[$a]['timezone']) . '"';
$room_ids = array_keys($rooms);
$params['id'] = 'rooms' . $a;
$params['options'] = $rooms;
$params['value'] = $room_ids[0];
$params['attributes'] = $attributes;
generate_select($params);
}
// No point telling them how to select multiple rooms if the input
// is disabled
if ($multiroom_allowed && !$disabled) {
echo "<span>" . get_vocab("ctrl_click") . "</span>\n";
}
echo "</div>\n";
echo "</div>\n";
}
示例5: date
echo "</thead>\n";
// TABLE BODY LISTING BOOKINGS
echo "<tbody>\n";
// This is the main bit of the display
// We loop through time and then the rooms we just got
// if the today is a day which includes a DST change then use
// the day after to generate timesteps through the day as this
// will ensure a constant time step
// URL for highlighting a time. Don't use REQUEST_URI or you will get
// the timetohighlight parameter duplicated each time you click.
$hilite_url = "day.php?year={$year}&month={$month}&day={$day}&area={$area}{$room_param}&timetohighlight";
$row_class = "even_row";
// We can display the table in two ways
if ($times_along_top) {
// with times along the top and rooms down the side
for ($i = 0; $row = sql_row_keyed($res, $i); $i++, $row_class = $row_class == "even_row" ? "odd_row" : "even_row") {
echo "<tr>\n";
$room_id = $row['id'];
$room_cell_link = "week.php?year={$year}&month={$month}&day={$day}&area={$area}&room={$room_id}";
draw_room_cell($row, $room_cell_link);
for ($t = mktime($morningstarts, $morningstarts_minutes, 0, $month, $day + $j, $year); $t <= mktime($eveningends, $eveningends_minutes, 0, $month, $day + $j, $year); $t += $resolution) {
// convert timestamps to HHMM format without leading zeros
$time_t = date($format, $t);
// and get a stripped version of the time for use with periods
$time_t_stripped = preg_replace("/^0/", "", $time_t);
// calculate hour and minute (needed for links)
$hour = date("H", $t);
$minute = date("i", $t);
// set up the query strings to be used for the link in the cell
$query_strings = array();
$query_strings['new_periods'] = "area={$area}&room={$room_id}&period={$time_t_stripped}&year={$year}&month={$month}&day={$day}";
示例6: get_vocab
echo "<p class=\"report_entries\"><span id=\"n_entries\">" . $nmatch . "</span> " . ($nmatch == 1 ? get_vocab("entry_found") : get_vocab("entries_found")) . "</p>\n";
}
// Report
if ($output == REPORT) {
open_report();
report_header();
$body_rows = array();
for ($i = 0; $row = sql_row_keyed($res, $i); $i++) {
report_row($body_rows, $row);
}
output_body_rows($body_rows, $output_format);
close_report();
} else {
open_summary();
if ($nmatch > 0) {
for ($i = 0; $row = sql_row_keyed($res, $i); $i++) {
accumulate($row, $count, $hours, $report_start, $report_end, $room_hash, $name_hash);
}
do_summary($count, $hours, $room_hash, $name_hash);
} else {
// Excel doesn't seem to like an empty file with just a BOM, so give
// it an empty row as well to keep it happy
$values = array();
output_row($values, $output_format);
}
close_summary();
}
}
}
if ($cli_mode) {
exit(0);
示例7: content_details
function content_details()
{
if ($this->content_id) {
$content_id = $this->content_id;
$sql = "SELECT c.id, c.content, c.mime_type, fc.duration FROM content c\n LEFT JOIN feed_content fc ON c.id = fc.content_id WHERE c.id = {$content_id} AND moderation_flag = 1;";
$res = sql_query($sql);
if ($res && sql_count($res)) {
$data = sql_row_keyed($res, 0);
$this->content_id = $data['id'];
$json['content'] = stripslashes($data['content']);
$json['mime_type'] = stripslashes($data['mime_type']);
$json['duration'] = $data['duration'];
if ($data['mime_type'] == 'text/time') {
//This executes time code
$json['mime_type'] = 'text/html';
$json['content'] = date($data['content']);
}
$this->log_back();
return $json;
} else {
$this->construct_timeline();
$this->get_content();
return $this->content_details();
}
} else {
$this->construct_timeline();
$this->get_content();
return $this->content_details();
}
}
示例8: avail_feeds
function avail_feeds(){
if($this->screen_set){
$sql = "SELECT id FROM feed WHERE id NOT IN (SELECT feed_id FROM position WHERE field_id = '$this->id' AND screen_id = '$this->screen_id') ORDER BY id ASC";
$res = sql_query($sql);
$i = 0;
while($feed_row = sql_row_keyed($res, $i)){
//$data[$i] = new Feed($feed_row['id']);
$feeds[$i] = $feed_row['id'];
$i++;
}
$obj = new Feed();
$access = $obj->priv_get(new Screen($this->screen_id), 'subscribe');
foreach($access as $feed){
$allowed[] = $feed->id;
}
$intersect = array_intersect($allowed, $feeds);
foreach($intersect as $feed_id){
$data[] = new Feed($feed_id);
}
return $data;
} else {
return false; //No screen = no fun! Get it through your head!
}
}
示例9: showAccessDenied
if (!getAuthorised(1)) {
showAccessDenied($day, $month, $year, $area, "");
exit;
}
} else {
$initial_user_creation = 1;
$user = "administrator";
$level = 2;
}
/*---------------------------------------------------------------------------*\
| Edit a given entry - 1st phase: Get the user input. |
\*---------------------------------------------------------------------------*/
if (isset($Action) && ($Action == "Edit" or $Action == "Add")) {
if ($Id >= 0) {
$result = sql_query("select * from {$tbl_users} where id={$Id}");
$data = sql_row_keyed($result, 0);
sql_free($result);
}
if ($Id == -1 || !$data) {
foreach ($fields as $fieldname) {
$data[$fieldname] = "";
}
}
/* First make sure the user is authorized */
if (!getWritable($data['name'], $user)) {
showAccessDenied(0, 0, 0, "", "");
exit;
}
print_header(0, 0, 0, 0, "");
print "<div id=\"form_container\">";
print "<form id=\"form_edit_users\" method=\"post\" action=\"" . htmlspecialchars(basename($PHP_SELF)) . "\">\n";
示例10: system_info
function system_info()
{
header("Content-type: text/xml");
echo '<?xml version="1.0"?>';
$sql = "SELECT id, name FROM feed WHERE type != 3";
$res = sql_query($sql);
$i = 0;
?>
<systeminfo>
<feeds>
<?php
while ($row = sql_row_keyed($res, $i)) {
?>
<feed>
<id><?php
echo $row['id'];
?>
</id>
<name><?php
echo htmlspecialchars($row['name']);
?>
</name>
</feed>
<?php
$i++;
}
?>
</feeds>
<?php
$sql = "SELECT name FROM type";
$res = sql_query($sql);
$i = 0;
?>
<types>
<?php
while ($row = sql_row_keyed($res, $i)) {
?>
<type><?php
echo htmlspecialchars($row['name']);
?>
</type>
<?php
$i++;
}
?>
</types>
</systeminfo>
<?php
}
示例11: get_for_user
function get_for_user($user_id, $hidden = 0, $since= '', $offset=0,$count = 5){
if(!is_numeric($user_id) || !is_numeric($offset) || !is_numeric($count)){
return false;
}
$hide_string = '';
if($hidden !== ''){
if(is_numeric($hidden)){
$hide_string = ' AND `hidden` = ' . $hidden;
} else {
return false;
}
}
$ts_string = '';
if($since != ''){
if($timestamp = strtotime($since)){
$ts_string = " AND `timestamp` > '" . date("Y-m-d G:i:s", $timestamp) . "' ";
} else {
return false;
}
}
$sql = 'SELECT newsfeed.id FROM newsfeed LEFT JOIN notifications ON newsfeed.notification_id = notifications.id WHERE user_id = ' . $user_id . $hide_string . $ts_string . ' ORDER BY notifications.timestamp DESC LIMIT ' . $offset . ' , ' . $count;
$res = sql_query($sql);
$notifs = array();
if($res != 0){
$i = 0;
while($row = sql_row_keyed($res, $i)){
$notifs[] = new Newsfeed($row['id']);
$i++;
}
}
return $notifs;
}
示例12: getPreviousEntryData
/**
* Gather all fields values for an entry. Used for emails to get previous
* entry state.
*
* @param int $id entry id to get data
* @param int $series 1 if this is a serie or 0
* @return bool TRUE or PEAR error object if fails
*/
function getPreviousEntryData($id, $series)
{
global $tbl_area, $tbl_entry, $tbl_repeat, $tbl_room, $enable_periods;
//
$sql = "\n SELECT e.name,\n e.description,\n e.create_by,\n r.room_name,\n a.area_name,\n e.type,\n e.room_id,\n e.repeat_id,\n e.timestamp,\n (e.end_time - e.start_time) AS tbl_e_duration,\n e.start_time AS tbl_e_start_time,\n e.end_time AS tbl_e_end_time,\n a.area_admin_email,\n r.room_admin_email";
// Here we could just use $tbl_repeat.start_time, and not use alias,
// as the last column will take precedence using mysql_fetch_array,
// but for portability purpose I will not use it.
if (1 == $series) {
$sql .= ", re.rep_type, re.rep_opt, re.rep_num_weeks,\n (re.end_time - re.start_time) AS tbl_r_duration,\n re.start_time AS tbl_r_start_time,\n re.end_time AS tbl_r_end_time,\n re.end_date AS tbl_r_end_date";
}
$sql .= "\n FROM {$tbl_entry} e, {$tbl_room} r, {$tbl_area} a ";
1 == $series ? $sql .= ', ' . $tbl_repeat . ' re ' : '';
$sql .= "\n WHERE e.room_id = r.id\n AND r.area_id = a.id\n AND e.id={$id}";
1 == $series ? $sql .= " AND e.repeat_id = re.id" : '';
//
$res = sql_query($sql);
!$res ? fatal_error(0, sql_error()) : '';
sql_count($res) < 1 ? fatal_error(0, get_string('invalid_entry_id', 'block_mrbs')) : '';
$row = sql_row_keyed($res, 0);
sql_free($res);
// Store all needed values in $mail_previous array to pass to
// notifyAdminOnDelete function (shorter than individual variables -:) )
$mail_previous['namebooker'] = $row['name'];
$mail_previous['description'] = $row['description'];
$mail_previous['createdby'] = $row['create_by'];
$mail_previous['room_name'] = $row['room_name'];
$mail_previous['area_name'] = $row['area_name'];
$mail_previous['type'] = $row['type'];
$mail_previous['room_id'] = $row['room_id'];
$mail_previous['repeat_id'] = $row['repeat_id'];
$mail_previous['updated'] = getMailTimeDateString($row[8]);
$mail_previous['area_admin_email'] = $row['area_admin_email'];
$mail_previous['room_admin_email'] = $row['room_admin_email'];
// If we use periods
if ($enable_periods) {
// If we delete a serie, start_time and end_time must
// come from $tbl_repeat, not $tbl_entry.
//
// This is not a serie
if (1 != $series) {
list($mail_previous['start_period'], $mail_previous['start_date']) = getMailPeriodDateString($row['tbl_e_start_time']);
list($mail_previous['end_period'], $mail_previous['end_date']) = getMailPeriodDateString($row['tbl_e_end_time'], -1);
// need to make DST correct in opposite direction to entry creation
// so that user see what he expects to see
$mail_previous['duration'] = $row['tbl_e_duration'] - cross_dst($row['tbl_e_start_time'], $row['tbl_e_end_time']);
} else {
list($mail_previous['start_period'], $mail_previous['start_date']) = getMailPeriodDateString($row['tbl_r_start_time']);
list($mail_previous['end_period'], $mail_previous['end_date']) = getMailPeriodDateString($row['tbl_r_end_time'], 0);
// use getMailTimeDateString as all I want is the date
$mail_previous['rep_end_date'] = getMailTimeDateString($row['tbl_r_end_date'], FALSE);
// need to make DST correct in opposite direction to entry creation
// so that user see what he expects to see
$mail_previous['duration'] = $row['tbl_r_duration'] - cross_dst($row['tbl_r_start_time'], $row['tbl_r_end_time']);
$mail_previous['rep_opt'] = "";
switch ($row['rep_type']) {
case 2:
case 6:
$rep_day[0] = $row['rep_opt'][0] != "0";
$rep_day[1] = $row['rep_opt'][1] != "0";
$rep_day[2] = $row['rep_opt'][2] != "0";
$rep_day[3] = $row['rep_opt'][3] != "0";
$rep_day[4] = $row['rep_opt'][4] != "0";
$rep_day[5] = $row['rep_opt'][5] != "0";
$rep_day[6] = $row['rep_opt'][6] != "0";
if ($row['rep_type'] == 6) {
$mail_previous['rep_num_weeks'] = $row['rep_num_weeks'];
} else {
$mail_previous['rep_num_weeks'] = "";
}
break;
default:
$rep_day = array(0, 0, 0, 0, 0, 0, 0);
}
for ($i = 0; $i < 7; $i++) {
$wday = ($i + $weekstarts) % 7;
if ($rep_day[$wday]) {
$mail_previous['rep_opt'] .= day_name($wday) . " ";
}
}
$mail_previous['rep_num_weeks'] = $row['rep_num_weeks'];
}
toPeriodString($mail_previous['start_period'], $mail_previous['duration'], $mail_previous['dur_units']);
} else {
// This is not a serie
if (1 != $series) {
$mail_previous['start_date'] = getMailTimeDateString($row['tbl_e_start_time']);
$mail_previous['end_date'] = getMailTimeDateString($row['tbl_e_end_time']);
// need to make DST correct in opposite direction to entry creation
// so that user see what he expects to see
$mail_previous['duration'] = $row['tbl_e_duration'] - cross_dst($row['tbl_e_start_time'], $row['tbl_e_end_time']);
} else {
//.........这里部分代码省略.........
示例13: COUNT
?>
</div>
<div class="menu_box_bot"><img border="0" src="<?= ADMIN_BASE_URL ?>images/menubox_bottom.gif" alt="" /></div>
</div>
<?php
if(isLoggedIn()) {
$sql = 'SELECT feed_content.feed_id as feed_id, COUNT(content.id) as cnt '.
'FROM feed_content '.
'LEFT JOIN content ON feed_content.content_id = content.id '.
'WHERE feed_content.moderation_flag IS NULL '.
'GROUP BY feed_content.feed_id;';
$res = sql_query($sql);
$more_waiting = 0;
for($i = 0;$row = sql_row_keyed($res,$i);++$i){
$count = $row['cnt'];
$feed = new Feed($row['feed_id']);
if($feed->user_priv($_SESSION['user'], 'moderate',true)) {
$mod_feeds[]="<p><a href=\"".ADMIN_URL."/moderate/feed/{$feed->id}\">" . htmlspecialchars($feed->name) . " ({$row['cnt']})</a></p>";
} else {
$more_waiting += $row['cnt'];
}
}
}
if(isset($mod_feeds) || ($more_waiting && isAdmin())) {
?>
<div class="alert_box">
<div class="alert_box_inset">
<div class="alert_box_padding">
<h1><a href="<?=ADMIN_URL?>/moderate">Awaiting Moderation</a></h1>
示例14: stats_byscreen
function stats_byscreen($time_period_in='yesterday'){
$time_period = escape($time_period_in);
$sql = "SELECT feed_id, " . $time_period . "_count FROM feed_content WHERE content_id = $this->id AND " . $time_period . "_count > 0";
$res = sql_query($sql);
$content_display_sum = 0;
$i=0;
while($row = sql_row_keyed($res, $i)){ //Generates a breakdown of displays per feed
$content_display_sum += $row[$time_period . '_count'];
$feed_distribution[$row['feed_id']] = $row[$time_period . '_count'];
$i++;
}
if($i > 0){ //Verify the content has been shown somewhere before we do all this math
foreach ($feed_distribution as $feed_id => $display_count){
$sql2 = "SELECT screen_id, SUM(" . $time_period . "_count) as " . $time_period . "_count FROM position WHERE feed_id = $feed_id AND " . $time_period . "_count > 0 GROUP BY screen_id";
$res2 = sql_query($sql2);
$feed_display_sum = 0;
$j = 0;
while($row2 = sql_row_keyed($res2, $j)){ //Generates a breakdown of displays per feed
$feed_display_sum += $row2[$time_period . '_count'];
$tempscreen_distribution[$row2['screen_id']] = $row2[$time_period . '_count'] * $display_count / $content_display_sum;
$j++;
}
$screen_distribution = array();
foreach ($tempscreen_distribution as $screen_id => $temp_calc){ //Reduce that to be on a per position percentage
if(!array_key_exists($screen_id, $screen_distribution)) {
$screen_distribution[$screen_id] = 0;
}
$screen_distribution[$screen_id] += $temp_calc / $feed_display_sum;
}
}
//Finally scale it up in terms of total content displayed
foreach ($screen_distribution as $screen_id => $temp_calc){
$screen_distribution[$screen_id] = round($temp_calc * $content_display_sum);
}
return $screen_distribution;
} else {
return 0; //The content hasn't been shown anywhere
}
}
示例15: sql_query
}elseif($type == 'all'){
$sql_base .= '';
}
//Don't forget the ordering
$sql_base .= ' ORDER BY id';
//End ordering
if(is_numeric($count)){
$sql_base .= " LIMIT $count";
}
//End SQL generation
//Run and process the query
$res = sql_query($sql_base);
if($res){
$i=0;
while($row = sql_row_keyed($res,$i)){
$data[$i] = $row;
$i++;
}
}
//End processing the query
//Verify we got content
if(!isset($data) || count($data) <= 0){
return false;
}
//End verification
//Now to start generating some display
if($format == 'raw'){
$content = $data[0]; //For images we only generate the first one