/**
 * Builds a basic query, returns string.
 *
 * @see http://api.drupal.org/api/function/db_query/6
 *
 * @param $query
 *   A string containing an SQL query.
 * @param ...
 *   A variable number of arguments which are substituted into the query
 *   using printf() syntax. Instead of a variable number of query arguments,
 *   you may also pass a single array containing the query arguments.
 *
 *   Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
 *   in '') and %%.
 *
 *   NOTE: using this syntax will cast NULL and FALSE values to decimal 0,
 *   and TRUE values to decimal 1.
 *
 * @return
 *   String of query that would have been run
 */
function my_return_query_string($query)
{
    $args = func_get_args();
    array_shift($args);
    $query = db_prefix_tables($query);
    if (isset($args[0]) and is_array($args[0])) {
        // 'All arguments in one array' syntax
        $args = $args[0];
    }
    _db_query_callback($args, TRUE);
    $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
    return $query;
}
예제 #2
0
 public function query_prefix($query)
 {
     // Inject table prefixes as needed.
     if (drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_DATABASE)) {
         // Enable prefix processing which can be dangerous so off by default. See http://drupal.org/node/1219850.
         if (drush_get_option('db-prefix')) {
             if (drush_drupal_major_version() >= 7) {
                 $query = Database::getConnection()->prefixTables($query);
             } else {
                 $query = db_prefix_tables($query);
             }
         }
     }
     return $query;
 }
<?php

/**
 * @file views-view-unformatted.tpl.php
 * Default simple view template to display a list of rows.
 *
 * @ingroup views_templates
 */
$v = views_get_current_view();
$query = db_prefix_tables(vsprintf($v->build_info['query'], $v->build_info['query_args']));
$replacements = module_invoke_all('views_query_substitutions', $v);
$query = str_replace(array_keys($replacements), $replacements, $query);
$drupal_base_path = base_path();
$country_list = db_query($query);
if (!empty($title)) {
    ?>
  <h3><?php 
    print $title;
    ?>
</h3>
<?php 
}
?>
<div class="country-list">
    <div class="ods-list">
<?php 
$count = 0;
while ($row = db_fetch_object($country_list)) {
    ?>
  <?php 
    if ($count % 4 == 0 || $count == 0) {
예제 #4
0
function db_query($sql)
{
    $newSQL = db_prefix_tables($sql);
    return mysql_query($newSQL);
}
예제 #5
0
function _os_poker_exec_sql($file)
{
    $results = array();
    if (is_file($file)) {
        $sql = file_get_contents($file);
        $queries = preg_split("/;\\s+/", $sql);
        foreach ($queries as $query) {
            if (!empty($query)) {
                $query = db_prefix_tables($query);
                $results[] = db_query($query);
            }
        }
    }
    return $results;
}