当前位置: 首页>>代码示例>>PHP>>正文


PHP serendipity_db_query函数代码示例

本文整理汇总了PHP中serendipity_db_query函数的典型用法代码示例。如果您正苦于以下问题:PHP serendipity_db_query函数的具体用法?PHP serendipity_db_query怎么用?PHP serendipity_db_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了serendipity_db_query函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: staticpage_display

function staticpage_display($params, &$smarty)
{
    global $serendipity;
    if (empty($params['template'])) {
        $params['template'] = 'plugin_staticpage.tpl';
    }
    if (empty($params['pagevar'])) {
        $params['pagevar'] = 'staticpage_';
    }
    if (!empty($params['id'])) {
        $where = "id = '" . serendipity_db_escape_string($params['id']) . "'";
    } elseif (!empty($params['pagetitle'])) {
        $where = "pagetitle = '" . serendipity_db_escape_string($params['pagetitle']) . "'";
    } elseif (!empty($params['permalink'])) {
        $where = "permalink = '" . serendipity_db_escape_string($params['permalink']) . "'";
    } else {
        $smarty->trigger_error(__FUNCTION__ . ": missing 'id', 'permalink' or 'pagetitle' parameter");
        return;
    }
    if (!empty($params['authorid'])) {
        $where .= " AND authorid = " . (int) $params['authorid'];
    }
    if (empty($params['query'])) {
        $params['query'] = "SELECT *\n                              FROM {$serendipity['dbPrefix']}staticpages\n                             WHERE {$where}\n                             LIMIT 1";
    }
    $page = serendipity_db_query($params['query'], true, 'assoc');
    if (is_array($page)) {
        $old_staticpage = $serendipity['staticpage_plugin']->staticpage;
        $serendipity['staticpage_plugin']->staticpage =& $page;
        $serendipity['staticpage_plugin']->checkPage();
        echo $serendipity['staticpage_plugin']->parseStaticPage($params['pagevar'], $params['template']);
        $serendipity['staticpage_plugin']->staticpage = $old_staticpage;
        return;
    }
}
开发者ID:sqall01,项目名称:additional_plugins,代码行数:35,代码来源:smarty.inc.php

示例2: addEntryProperties

 static function addEntryProperties($entryId, $supported_properties, &$properties, $deleteMissing = true)
 {
     global $serendipity;
     // Get existing data
     $property = serendipity_fetchEntryProperties($entryId);
     foreach ($supported_properties as $prop_key) {
         $prop_val = isset($properties[$prop_key]) ? $properties[$prop_key] : null;
         if (!$deleteMissing && empty($prop_val)) {
             continue;
         }
         // Don't clear data if not allowed.
         $q = '';
         if (!isset($property[$prop_key]) && !empty($prop_val)) {
             if ($prop_val != '#') {
                 $q = "INSERT INTO {$serendipity['dbPrefix']}entryproperties (entryid, property, value) VALUES (" . (int) $entryId . ", '" . serendipity_db_escape_string($prop_key) . "', '" . serendipity_db_escape_string($prop_val) . "')";
             }
         } elseif ($property[$prop_key] != $prop_val && !empty($prop_val)) {
             if ($prop_val == '#') {
                 $q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int) $entryId . " AND property = '" . serendipity_db_escape_string($prop_key) . "'";
             } else {
                 $q = "UPDATE {$serendipity['dbPrefix']}entryproperties SET value = '" . serendipity_db_escape_string($prop_val) . "' WHERE entryid = " . (int) $entryId . " AND property = '" . serendipity_db_escape_string($prop_key) . "'";
             }
         } elseif (empty($property[$prop_key])) {
             $q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int) $entryId . " AND property = '" . serendipity_db_escape_string($prop_key) . "'";
         }
         if (!empty($q)) {
             serendipity_db_query($q);
         }
     }
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:30,代码来源:GeoTagDb.class.php

示例3: set_config

 function set_config($item, $value)
 {
     global $serendipity;
     serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}options\n                               WHERE okey = 't_" . serendipity_db_escape_string($serendipity['template']) . "'\n                                 AND name = '" . serendipity_db_escape_string($item) . "'");
     serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}options (okey, name, value)\n                                   VALUES ('t_" . serendipity_db_escape_string($serendipity['template']) . "', '" . serendipity_db_escape_string($item) . "', '" . serendipity_db_escape_string($value) . "')");
     return true;
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:7,代码来源:templates.inc.php

示例4: generate_content

 function generate_content(&$title)
 {
     global $serendipity;
     $number = $this->get_config('number');
     $showpicsonly = $this->get_config('showpicsonly');
     if (!$number || !is_numeric($number) || $number < 1) {
         $number = 5;
     }
     $title = PLUGIN_PHOTOBLOG_TITLE;
     if (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id'])) {
         $number = $number * $number + 1;
         $entries = serendipity_db_query("SELECT id,\n                                                title,\n                                                timestamp\n                                           FROM {$serendipity['dbPrefix']}entries\n                                          WHERE isdraft = 'false'\n                                       ORDER BY timestamp DESC\n                                          LIMIT {$number}");
     } else {
         $id = serendipity_db_escape_string($serendipity['GET']['id']);
         $entries1 = serendipity_db_query("SELECT id,\n                                                title,\n                                                timestamp\n                                           FROM {$serendipity['dbPrefix']}entries\n                                          WHERE isdraft = 'false'\n                                            AND id > {$id}\n                                       ORDER BY timestamp ASC\n                                          LIMIT {$number}");
         $number++;
         $entries2 = serendipity_db_query("SELECT id,\n                                                title,\n                                                timestamp\n                                           FROM {$serendipity['dbPrefix']}entries\n                                          WHERE isdraft = 'false'\n                                            AND id <= {$id}\n                                       ORDER BY timestamp DESC\n                                          LIMIT {$number}");
         if (isset($entries1) && is_array($entries1) && isset($entries2) && is_array($entries2)) {
             $entries = array_merge(array_reverse($entries1), $entries2);
         } elseif (isset($entries1) && is_array($entries1)) {
             $entries = array_reverse($entries1);
         } elseif (isset($entries2) && is_array($entries2)) {
             $entries = $entries2;
         }
     }
     if (isset($entries) && is_array($entries)) {
         foreach ($entries as $k => $entry) {
             $entryLink = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
             $photo = $this->getPhoto($entry['id']);
             if ($showpicsonly == 'true' && isset($photo) || $showpicsonly != 'true') {
                 if (isset($photo)) {
                     $file = serendipity_fetchImageFromDatabase($photo['photoid']);
                     $imgsrc = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension'];
                     $thumbbasename = $file['path'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension'];
                     $thumbName = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $thumbbasename;
                     $thumbsize = @getimagesize($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $thumbbasename);
                 }
                 echo '<a href="' . $entryLink . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '">';
                 if (isset($photo)) {
                     echo '<img style="margin:5px;" src="' . $imgsrc . '" width=' . $thumbsize[0] . ' height=' . $thumbsize[1];
                     if (isset($id) && $id == $entry['id']) {
                         echo ' border=4';
                     }
                     echo ' />';
                 } else {
                     if (isset($id) && $id == $entry['id']) {
                         echo '<b>';
                     }
                     echo $entry['title'];
                     if (isset($id) && $id == $entry['id']) {
                         echo '</b>';
                     }
                 }
                 echo '</a><br />';
             }
         }
     }
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:58,代码来源:serendipity_plugin_photoblog.php

示例5: serendipity_addDefaultGroups

/**
 * Create default groups, when migrating.
 *
 * @access private
 */
function serendipity_addDefaultGroups()
{
    global $serendipity;
    serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}groups");
    serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}groupconfig");
    serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}authorgroups");
    serendipity_addDefaultGroup(USERLEVEL_EDITOR_DESC, USERLEVEL_EDITOR);
    serendipity_addDefaultGroup(USERLEVEL_CHIEF_DESC, USERLEVEL_CHIEF);
    serendipity_addDefaultGroup(USERLEVEL_ADMIN_DESC, USERLEVEL_ADMIN);
}
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:15,代码来源:functions_upgrader.inc.php

示例6: showSearch

 function showSearch()
 {
     global $serendipity;
     $this->setupDB();
     $term = serendipity_db_escape_string($serendipity['GET']['searchTerm']);
     if ($serendipity['dbType'] == 'postgres') {
         $group = '';
         $distinct = 'DISTINCT';
         $find_part = "(c.title ILIKE '%{$term}%' OR c.body ILIKE '%{$term}%')";
     } elseif ($serendipity['dbType'] == 'sqlite') {
         $group = 'GROUP BY id';
         $distinct = '';
         $term = serendipity_mb('strtolower', $term);
         $find_part = "(lower(c.title) LIKE '%{$term}%' OR lower(c.body) LIKE '%{$term}%')";
     } else {
         $group = 'GROUP BY id';
         $distinct = '';
         $term = str_replace('&quot;', '"', $term);
         if (preg_match('@["\\+\\-\\*~<>\\(\\)]+@', $term)) {
             $find_part = "MATCH(c.title,c.body) AGAINST('{$term}' IN BOOLEAN MODE)";
         } else {
             $find_part = "MATCH(c.title,c.body) AGAINST('{$term}')";
         }
     }
     $querystring = "SELECT c.title AS ctitle, c.body, c.author, c.entry_id, c.timestamp AS ctimestamp, c.url, c.type,\n                               e.id, e.title, e.timestamp\n                          FROM {$serendipity['dbPrefix']}comments AS c\n               LEFT OUTER JOIN {$serendipity['dbPrefix']}entries AS e\n                            ON e.id = c.entry_id\n                         WHERE c.status = 'approved'\n                           AND {$find_part}\n                               {$group}\n                      ORDER BY c.timestamp DESC";
     $results = serendipity_db_query($querystring, false, 'assoc');
     if (!is_array($results)) {
         if ($results !== 1 && $results !== true) {
             echo function_exists('serendipity_specialchars') ? serendipity_specialchars($results) : htmlspecialchars($results, ENT_COMPAT, LANG_CHARSET);
         }
         $results = array();
     }
     $myAddData = array("from" => "serendipity_plugin_commentsearch:generate_content");
     foreach ($results as $idx => $result) {
         $results[$idx]['permalink'] = serendipity_archiveURL($result['id'], $result['title'], 'baseURL', true, $result);
         $results[$idx]['comment'] = $result['body'];
         //(function_exists('serendipity_specialchars') ? serendipity_specialchars(strip_tags($result['body'])) : htmlspecialchars(strip_tags($result['body']), ENT_COMPAT, LANG_CHARSET));
         serendipity_plugin_api::hook_event('frontend_display', $results[$idx], $myAddData);
         // let the template decide, if we want to have tags or not
         $results[$idx]['commenthtml'] = $results[$idx]['comment'];
         $results[$idx]['comment'] = strip_tags($results[$idx]['comment']);
     }
     $serendipity['smarty']->assign(array('comment_searchresults' => count($results), 'comment_results' => $results));
     $filename = 'plugin_commentsearch_searchresults.tpl';
     $tfile = serendipity_getTemplateFile($filename, 'serendipityPath');
     if (!$tfile) {
         $tfile = dirname(__FILE__) . '/' . $filename;
     }
     $inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY];
     $serendipity['smarty']->security_settings[INCLUDE_ANY] = true;
     $content = $serendipity['smarty']->fetch('file:' . $tfile);
     $serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion;
     echo $content;
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:54,代码来源:serendipity_event_commentsearch.php

示例7: table_created

 static function table_created($table = PLUGIN_OEMBED_DATABASEVNAME)
 {
     global $serendipity;
     $q = "select count(*) from {$serendipity['dbPrefix']}" . $table;
     $row = serendipity_db_query($q, true, 'num');
     if (!is_numeric($row[0])) {
         // if the response we got back was an SQL error.. :P
         return false;
     } else {
         return true;
     }
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:12,代码来源:OEmbedDatabase.php

示例8: doReorder

 /**
  * Update table for re-ordering
  *
  * @access public
  * @author Falk Doering
  * @param  string  Name of the table
  * @param  string  The direction ('up' or 'down')
  * @param  array   The update array
  * @param  array   The array containing the where clause
  * @return boolean
  */
 function doReorder($table, $moveto, $update_array, $where_array)
 {
     global $serendipity;
     if (is_array($update_array) && is_array($where_array)) {
         $where = '';
         foreach ($where_array as $key => $value) {
             if (strlen($where)) {
                 $where .= ' AND ';
             }
             $where .= $key . ' = ' . $value;
         }
         $q = 'SELECT ' . implode(", ", array_keys($update_array)) . '
                 FROM ' . $serendipity['dbPrefix'] . $table . '
                WHERE ' . $where;
         $old = serendipity_db_query($q, true, 'assoc');
         if (is_array($old)) {
             $where = array();
             $update = array();
             switch ($moveto) {
                 case 'up':
                     foreach ($update_array as $key => $value) {
                         if ($value) {
                             $where[$key] = $old[$key] - 1;
                             $update[$key] = $old[$key];
                             $update_1[$key] = $old[$key] - 1;
                         } else {
                             $where[$key] = $old[$key];
                         }
                     }
                     break;
                 case 'down':
                     foreach ($update_array as $key => $value) {
                         if ($value) {
                             $where[$key] = $old[$key] + 1;
                             $update[$key] = $old[$key];
                             $update_1[$key] = $old[$key] + 1;
                         } else {
                             $where[$key] = $old[$key];
                         }
                     }
                     break;
                 default:
                     return false;
             }
             serendipity_db_update($table, $where, $update);
             serendipity_db_update($table, $where_array, $update_1);
             return true;
         }
     }
     return false;
 }
开发者ID:vonnordmann,项目名称:Serendipity,代码行数:62,代码来源:plugin_api_extension.inc.php

示例9: generate_content

 function generate_content(&$title)
 {
     global $serendipity;
     $title = THUMBPAGE_TITLE;
     if ($serendipity['GET']['page'] != 'thumbs') {
         return true;
     }
     if (!headers_sent()) {
         header('HTTP/1.0 200');
         header('Status: 200 OK');
     }
     $entries = serendipity_db_query("SELECT id,\n                                                title,\n                                                timestamp\n                                           FROM {$serendipity['dbPrefix']}entries\n                                          WHERE isdraft = 'false'\n                                       ORDER BY timestamp DESC");
     if (isset($entries) && is_array($entries)) {
         $count = 0;
         echo '<table><tr>';
         foreach ($entries as $k => $entry) {
             echo '<td align="center">';
             $entryLink = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp']));
             $photo = $this->getPhoto($entry['id']);
             if (isset($photo)) {
                 $file = serendipity_fetchImageFromDatabase($photo['photoid']);
                 $imgsrc = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension'];
                 $thumbbasename = $file['path'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension'];
                 $thumbName = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $thumbbasename;
                 $thumbsize = @getimagesize($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $thumbbasename);
             }
             echo '<a href="' . $entryLink . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '">';
             if (isset($photo)) {
                 echo '<img style="margin:5px;" src="' . $imgsrc . '" width=' . $thumbsize[0] . ' height=' . $thumbsize[1];
                 if (isset($id) && $id == $entry['id']) {
                     echo ' border=4';
                 }
                 echo ' />';
             } else {
                 if (isset($id) && $id == $entry['id']) {
                     echo '<b>';
                 }
                 echo $entry['title'];
                 if (isset($id) && $id == $entry['id']) {
                     echo '</b>';
                 }
             }
             echo '</a></td>';
             if ($count++ >= $this->get_config('number') - 1) {
                 $count = 0;
                 echo "</tr><tr>";
             }
         }
         echo "</tr></table>";
     }
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:51,代码来源:serendipity_event_thumbnails.php

示例10: event_hook

 function event_hook($event, &$bag, &$eventData, $addData = null)
 {
     global $serendipity;
     $hooks =& $bag->get('event_hooks');
     if (isset($hooks[$event])) {
         switch ($event) {
             case 'frontend_display':
                 if ($bag->get('scrambles_true_content') && is_array($addData) && isset($addData['no_scramble'])) {
                     return true;
                 }
             case 'frontend_display_cache':
                 $serendipity['encodeExitsCallback_entry_id'] = (int) (isset($eventData['entry_id']) ? $eventData['entry_id'] : $eventData['id']);
                 // Fetch all existing links from the database. They have been inserted there by our trackback-discovery.
                 if (empty($serendipity['encodeExitsCallback_entry_id'])) {
                     $this->links = array();
                 } else {
                     #echo "SELECT id, link FROM {$serendipity['dbPrefix']}references WHERE entry_id = {$serendipity['encodeExitsCallback_entry_id']} AND type = ''<br />\n";
                     $this->links = serendipity_db_query("SELECT id, link FROM {$serendipity['dbPrefix']}references WHERE entry_id = {$serendipity['encodeExitsCallback_entry_id']} AND (type = '' OR type IS NULL)", false, 'both', false, 'link', 'id');
                     #echo "<pre>" . print_r($this->links, true) . "</pre><br />\n";
                 }
                 foreach ($this->markup_elements as $temp) {
                     if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']]) && !$eventData['properties']['ep_disable_markup_' . $this->instance] && !isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) {
                         $element = $temp['element'];
                         $eventData[$element] = preg_replace_callback("#<a(.*)href=(\"|')http(s?)://([^\"']+)(\"|')([^>]*)>#isUm", array($this, '_encodeExitsCallback'), $eventData[$element]);
                         if ($temp['element'] == 'comment' && !empty($eventData['url'])) {
                             switch (trim($this->get_config('commentredirection'))) {
                                 case 'bmi':
                                     $eventData['url'] = 'http://bmi.pifo.biz/?' . $eventData['url'];
                                     break;
                                 case 's9y':
                                     $eventData['url'] = $this->_encodeExitsCallback(array(1 => ' ', 2 => '"', 3 => '', 4 => $eventData['url'], 5 => '"'), true);
                                     break;
                                 case 'google':
                                     $eventData['url'] = 'http://www.google.com/url?sa=D&q=' . $eventData['url'];
                                     break;
                                 default:
                                     break;
                             }
                         }
                     }
                 }
                 return true;
                 break;
             default:
                 return false;
         }
     } else {
         return false;
     }
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:50,代码来源:serendipity_event_trackexits.php

示例11: order_to_first

 function order_to_first()
 {
     global $serendipity;
     // Fetch minimum sort_order value. This will be the new value of our current plugin.
     $q = "SELECT MIN(sort_order) as sort_order_min FROM {$serendipity['dbPrefix']}plugins WHERE placement = '" . $addData['default_placement'] . "'";
     $rs = serendipity_db_query($q, true, 'num');
     // Fetch current sort_order of current plugin.
     $q = "SELECT sort_order FROM {$serendipity['dbPrefix']}plugins WHERE name = '" . $this->instance . "'";
     $cur = serendipity_db_query($q, true, 'num');
     // Increase sort_order of all plugins before current plugin by one.
     $q = "UPDATE {$serendipity['dbPrefix']}plugins SET sort_order = sort_order + 1 WHERE placement = '" . $addData['default_placement'] . "' AND sort_order < " . intval($cur[0]);
     serendipity_db_query($q);
     // Set current plugin as first plugin in queue.
     $q = "UPDATE {$serendipity['dbPrefix']}plugins SET sort_order = " . intval($rs[0]) . " WHERE name = '" . $this->instance . "'";
     serendipity_db_query($q);
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:16,代码来源:serendipity_event_jquery.php

示例12: AND

/**
 * Fetch a list of trackbacks for an entry
 *
 * @access public
 * @param   int     The ID of the entry
 * @param   string  How many trackbacks to show
 * @param   boolean If true, also non-approved trackbacks will be shown
 * @return
 */
function &serendipity_fetchTrackbacks($id, $limit = null, $showAll = false)
{
    global $serendipity;
    if (!$showAll) {
        $and = "AND status = 'approved'";
    }
    $query = "SELECT * FROM {$serendipity['dbPrefix']}comments WHERE entry_id = '" . (int) $id . "' AND (type = 'TRACKBACK' OR type = 'PINGBACK') {$and} ORDER BY id";
    if (isset($limit)) {
        $limit = serendipity_db_limit_sql($limit);
        $query .= " {$limit}";
    }
    $comments = serendipity_db_query($query);
    if (!is_array($comments)) {
        return array();
    }
    return $comments;
}
开发者ID:REAP720801,项目名称:Serendipity,代码行数:26,代码来源:functions_smarty.inc.php

示例13: generate_content

 function generate_content(&$title)
 {
     global $serendipity;
     $title = $this->get_config('title', $this->title);
     $authors_query = "SELECT realname, username, authorid FROM {$serendipity['dbPrefix']}authors";
     $row_authors = serendipity_db_query($authors_query);
     echo '<ul class="plainList">';
     foreach ($row_authors as $entry) {
         if (function_exists('serendipity_authorURL')) {
             $entryLink = serendipity_authorURL($entry);
         } else {
             $entryLink = serendipity_rewriteURL(PATH_AUTHORS . '/' . serendipity_makePermalink(PERM_AUTHORS, array('id' => $entry['authorid'], 'title' => $entry['realname'])));
         }
         echo '<li><a href="' . $entryLink . '">' . $entry['realname'] . '</a></li>';
     }
     echo '</ul>';
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:17,代码来源:serendipity_plugin_authors.php

示例14: serendipity_db_insert

/**
 * Perform a query to insert an associative array into a specific SQL table
 *
 * You can pass a tablename and an array of input data to insert into an array.
 *
 * @access  public
 * @param   string      Name of the SQL table
 * @param   array       Associative array of keys/values to insert into the table. Escaping is done automatically.
 * @param  string   What do do with the SQL query (execute, display)
 * @return array    Returns the result of the SQL query
 */
function serendipity_db_insert($table, $values, $action = 'execute')
{
    global $serendipity;
    $names = implode(',', array_keys($values));
    $vals = '';
    foreach ($values as $k => $v) {
        if (strlen($vals)) {
            $vals .= ', ';
        }
        $vals .= '\'' . serendipity_db_escape_string($v) . '\'';
    }
    $q = "INSERT INTO {$serendipity['dbPrefix']}{$table} ({$names}) values ({$vals})";
    if ($action == 'execute') {
        return serendipity_db_query($q);
    } else {
        return $q;
    }
}
开发者ID:rustyx,项目名称:Serendipity,代码行数:29,代码来源:db.inc.php

示例15: generate_content

 function generate_content(&$title)
 {
     global $serendipity;
     $title = $this->get_config('title');
     $count = $this->get_config('count');
     if ($count < 1) {
         $count = 1;
     }
     $rows = serendipity_db_query("select {$serendipity['dbPrefix']}authors.username,\nSUM({$serendipity['dbPrefix']}karma.points) as score, SUM({$serendipity['dbPrefix']}karma.votes) as\nvotes,SUM({$serendipity['dbPrefix']}karma.points) / SUM({$serendipity['dbPrefix']}karma.votes) as overall FROM\n{$serendipity['dbPrefix']}entries, {$serendipity['dbPrefix']}karma, {$serendipity['dbPrefix']}authors WHERE {$serendipity['dbPrefix']}entries.id = {$serendipity['dbPrefix']}karma.entryid\nAND {$serendipity['dbPrefix']}authors.authorid = {$serendipity['dbPrefix']}entries.authorid " . "GROUP BY {$serendipity['dbPrefix']}authors.username ORDER BY score DESC; ");
     echo "<table>";
     echo "<tr><th style='background-color: #DDDDDD'>" . PLUGIN_KARMARANKING_AUTHOR . "</th>";
     echo "<th style='background-color: #DDDDDD'>" . PLUGIN_KARMARANKING_TOTAL . "</th></tr>";
     #var_dump($rows);
     foreach ($rows as $row) {
         echo "<tr><td>" . $row[0] . "</td><td style='text-align: center'>" . $row[1] . "</td></tr>";
     }
     echo "</table>";
 }
开发者ID:sqall01,项目名称:additional_plugins,代码行数:18,代码来源:serendipity_plugin_karmaranking.php


注:本文中的serendipity_db_query函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。