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


PHP sql函数代码示例

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


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

示例1: assignFromDB

function assignFromDB($userid)
{
    global $tpl, $opt;
    $rs = sql("SELECT `p`.`id`, IFNULL(`tt`.`text`, `p`.`name`) AS `name`, `p`.`default_value`, `p`.`check_regex`, `p`.`option_order`, `u`.`option_visible`, `p`.`internal_use`, `p`.`option_input`, IFNULL(`u`.`option_value`, `p`.`default_value`) AS `option_value`\r\n\t\t           FROM `profile_options` AS `p`\r\n\t\t      LEFT JOIN `user_options` AS `u` ON `p`.`id`=`u`.`option_id` AND (`u`.`user_id` IS NULL OR `u`.`user_id`='&1')\r\n\t\t      LEFT JOIN `sys_trans` AS `st` ON `p`.`trans_id`=`st`.`id` AND `p`.`name`=`st`.`text`\r\n\t\t      LEFT JOIN `sys_trans_text` AS `tt` ON `st`.`id`=`tt`.`trans_id` AND `tt`.`lang`='&2'\r\n\t\t       ORDER BY `p`.`internal_use` DESC, `p`.`option_order`", $userid + 0, $opt['template']['locale']);
    $tpl->assign_rs('useroptions', $rs);
    sql_free_result($rs);
}
开发者ID:RH-Code,项目名称:opencaching,代码行数:7,代码来源:mydetails.php

示例2: run

 public function run()
 {
     sql('set @allowdelete=1');
     sql('DELETE FROM `user`
         WHERE `date_created`<DATE_ADD(NOW(), INTERVAL -21 DAY)
         AND `is_active_flag`=0 AND `activation_code`!=\'\'');
 }
开发者ID:kratenko,项目名称:oc-server3,代码行数:7,代码来源:user_delete.class.php

示例3: find

function find($gamearr)
{
    $number_of_games = count($gamearr);
    if ($number_of_games == 0) {
        echo "No Game Choosen.";
    } else {
        $table = [];
        $max_cpu = 0;
        $max_gpu = 0;
        for ($i = 0; $i < $number_of_games; $i++) {
            $sql = "SELECT cpuscore, gpuscore FROM game WHERE game.name LIKE'%{$gamearr[$i]}%'";
            $result = sql($sql, 1);
            $row = $result->fetch_assoc();
            //echo 'cpuscore: '.$row['cpuscore'];
            $table[$i] = $row;
        }
        // 'cpuscore: '.$table[0]['cpuscore']. '  gpuscore: '.$table[0]['gpuscore'];
        for ($x = 0; $x < $number_of_games; $x++) {
            $cur_cpuscore = $table[$x]['cpuscore'];
            $cur_gpuscore = $table[$x]['gpuscore'];
            if ($cur_cpuscore > $max_cpu) {
                $max_cpu = $cur_cpuscore;
            }
            if ($cur_gpuscore > $max_gpu) {
                $max_gpu = $cur_gpuscore;
            }
        }
        echo 'needed cpu score:  ' . $max_cpu . '  needed gpu score: ' . $max_gpu;
    }
}
开发者ID:tsunderen,项目名称:projecto1,代码行数:30,代码来源:gameq.php

示例4: create_databases

function create_databases($base) {
    $tables = array($base . 'cache', $base . 'meta', $base . 'stats');
    sql('DROP TABLE IF EXISTS ' . implode(',', $tables));

    sql('CREATE TABLE ' . $base . 'cache (' .
            'id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,' .
            'url VARCHAR(255),' .
            'lastscanned DATETIME, ' .
            'jsondata TEXT, ' .
            'start INT UNSIGNED, ' .
            'end INT UNSIGNED' .
            ')');
    // TODO: Add UNIQUE key to url, start, end.
    sql('CREATE TABLE ' . $base . 'meta (' .
            'id VARCHAR(20) PRIMARY KEY,' .
            'lastscanned DATETIME, ' .
            'jsondata TEXT' .
            ')');
        
    sql('CREATE TABLE ' . $base . 'stats (' .
            'name VARCHAR(100), ' .
            'message VARCHAR(255), ' .
            'timestamp DATETIME, ' .
            'microtime INT UNSIGNED' .
            ')');
    
}
开发者ID:rlf,项目名称:icefilms-boxee,代码行数:27,代码来源:create_db.php

示例5: mq_edit

function mq_edit($p, $o, $res = '')
{
    list($p, $o) = ajxp($res, $p, $o);
    $r = sql('select ' . $p . ' from ' . $o . ';', '');
    //if($r)foreach($r as $v)$ret.=lj('','popup_plup___mysqm_mq*edit_'.$v[0],$v[0]);
    return $ret;
}
开发者ID:philum,项目名称:cms,代码行数:7,代码来源:mysqm.php

示例6: getAttrbutesListArrayInternal

 static function getAttrbutesListArrayInternal($cacheId, $bOnlySelectable)
 {
     global $opt;
     $attributes = array();
     $rsAttrGroup = sql("SELECT `attribute_groups`.`id`, \r\n\t\t                           IFNULL(`tt1`.`text`, `attribute_groups`.`name`) AS `name`, \r\n\t\t                           IFNULL(`tt2`.`text`, `attribute_categories`.`name`) AS `category`, \r\n\t\t                           `attribute_categories`.`color`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `attribute_groups` \r\n\t\t\t\t\t\t\t\t\t\tINNER JOIN `attribute_categories` ON `attribute_groups`.`category_id`=`attribute_categories`.`id`\r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN `sys_trans` AS `t1` ON `attribute_groups`.`trans_id`=`t1`.`id` AND `attribute_groups`.`name`=`t1`.`text` \r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN `sys_trans_text` AS `tt1` ON `t1`.`id`=`tt1`.`trans_id` AND `tt1`.`lang`='&1' \r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN `sys_trans` AS `t2` ON `attribute_categories`.`trans_id`=`t2`.`id` AND `attribute_categories`.`name`=`t2`.`text` \r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN `sys_trans_text` AS `tt2` ON `t2`.`id`=`tt2`.`trans_id` AND `tt2`.`lang`='&1' \r\n\t\t\t\t\t\t\t\t\t\t\tORDER BY `attribute_groups`.`id` ASC", $opt['template']['locale']);
     while ($rAttrGroup = sql_fetch_assoc($rsAttrGroup)) {
         $attr = array();
         $bFirst = true;
         if ($cacheId == 0) {
             $sAddWhereSql = '';
             if ($bOnlySelectable == true) {
                 $sAddWhereSql = ' AND `cache_attrib`.`selectable`=1';
             }
             $rsAttr = sql("SELECT `cache_attrib`.`id`, IFNULL(`tt1`.`text`, `cache_attrib`.`name`) AS `name`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIFNULL(`tt2`.`text`, `cache_attrib`.`html_desc`) AS `html_desc`, `cache_attrib`.`icon`\r\n\t\t\t\t\t\t\t\t\t\t\t\t FROM `cache_attrib`\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans` AS `t1` ON `cache_attrib`.`trans_id`=`t1`.`id` AND `cache_attrib`.`name`=`t1`.`text` \r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt1` ON `t1`.`id`=`tt1`.`trans_id` AND `tt1`.`lang`='&1' \r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans` AS `t2` ON `cache_attrib`.`html_desc_trans_id`=`t2`.`id` \r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt2` ON `t2`.`id`=`tt2`.`trans_id` AND `tt2`.`lang`='&1' \r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `cache_attrib`.`group_id`='&2'\r\n\t\t\t\t\t\t\t\t\t\t\t\tAND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1\r\n\t\t\t\t\t\t\t\t\t\t ORDER BY `cache_attrib`.`group_id` ASC", $opt['template']['locale'], $rAttrGroup['id']);
         } else {
             $rsAttr = sql("SELECT `cache_attrib`.`id`, IFNULL(`tt1`.`text`, `cache_attrib`.`name`) AS `name`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIFNULL(`tt2`.`text`, `cache_attrib`.`html_desc`) AS `html_desc`, `cache_attrib`.`icon`\r\n\t\t\t\t\t\t\t\t\t\t\t\t FROM `caches_attributes` \r\n\t\t\t\t\t\t\t\t\t INNER JOIN `cache_attrib` ON `caches_attributes`.`attrib_id`=`cache_attrib`.`id` \r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans` AS `t1` ON `cache_attrib`.`trans_id`=`t1`.`id` AND `cache_attrib`.`name`=`t1`.`text` \r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt1` ON `t1`.`id`=`tt1`.`trans_id` AND `tt1`.`lang`='&2' \r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans` AS `t2` ON `cache_attrib`.`html_desc_trans_id`=`t2`.`id` \r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt2` ON `t2`.`id`=`tt2`.`trans_id` AND `tt2`.`lang`='&2' \r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `caches_attributes`.`cache_id`='&1' AND `cache_attrib`.`group_id`='&3'\r\n\t\t\t\t\t\t\t\t\t\t\t\tAND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1\r\n\t\t\t\t\t\t\t\t\t\t ORDER BY `cache_attrib`.`group_id` ASC", $cacheId, $opt['template']['locale'], $rAttrGroup['id']);
         }
         while ($rAttr = sql_fetch_assoc($rsAttr)) {
             $attr[] = $rAttr;
         }
         sql_free_result($rsAttr);
         if (count($attr) > 0) {
             $attributes[] = array('name' => $rAttrGroup['name'], 'color' => $rAttrGroup['color'], 'category' => $rAttrGroup['category'], 'attr' => $attr);
         }
     }
     sql_free_result($rsAttrGroup);
     return $attributes;
 }
开发者ID:RH-Code,项目名称:opencaching,代码行数:28,代码来源:attribute.class.php

示例7: queues_check_compoundrecordings

function queues_check_compoundrecordings()
{
    global $db;
    $compound_recordings = array();
    $sql = "SELECT extension, descr, agentannounce_id, ivr_id FROM queues_config WHERE (ivr_id != 'none' AND ivr_id != '') OR agentannounce_id != ''";
    $results = sql($sql, "getAll", DB_FETCHMODE_ASSOC);
    if (function_exists('ivr_get_details')) {
        $ivr_details = ivr_get_details();
        foreach ($ivr_details as $item) {
            $ivr_hash[$item['id']] = $item;
        }
        $check_ivr = true;
    } else {
        $check_ivr = false;
    }
    foreach ($results as $result) {
        $agentannounce = $result['agentannounce_id'] ? recordings_get_file($result['agentannounce_id']) : '';
        if (strpos($agentannounce, "&") !== false) {
            $compound_recordings[] = array('extension' => $result['extension'], 'descr' => $result['descr'], 'error' => _("Agent Announce Msg"));
        }
        if ($result['ivr_id'] != 'none' && $result['ivr_id'] != '' && $check_ivr) {
            $id = $ivr_hash[$result['ivr_id']]['announcement_id'];
            $announce = $id ? recordings_get_file($id) : '';
            if (strpos($announce, "&") !== false) {
                $compound_recordings[] = array('extension' => $result['extension'], 'descr' => $result['descr'], 'error' => sprintf(_("IVR Announce: %s"), $ivr_hash[$result['ivr_id']]['displayname']));
            }
        }
    }
    return $compound_recordings;
}
开发者ID:ringfreejohn,项目名称:pbxframework,代码行数:30,代码来源:functions.inc.php

示例8: run

 public function run()
 {
     $rsCache = sql("SELECT `cache_id`, `latitude`, `longitude` FROM `caches` WHERE `need_npa_recalc`=1");
     while ($rCache = sql_fetch_assoc($rsCache)) {
         sql("DELETE FROM `cache_npa_areas` WHERE `cache_id`='&1' AND `calculated`=1", $rCache['cache_id']);
         $rsLayers = sql("SELECT `id`, `type_id`, AsText(`shape`) AS `geometry` \n                FROM `npa_areas` WHERE `exclude`=0 AND MBRWITHIN(GeomFromText('&1'), `shape`)", 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
         while ($rLayers = sql_fetch_assoc($rsLayers)) {
             if (gis::ptInLineRing($rLayers['geometry'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')')) {
                 $bExclude = false;
                 // prüfen, ob in ausgesparter Fläche
                 $rsExclude = sql("SELECT `id`, AsText(`shape`) AS `geometry`\n                        FROM `npa_areas`\n                        WHERE `exclude` = 1\n                        AND `type_id`='&1'\n                        AND MBRWITHIN(GeomFromText('&2'), `shape`)", $rLayers['type_id'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
                 while (($rExclude = sql_fetch_assoc($rsExclude)) && $bExclude == false) {
                     if (gis::ptInLineRing($rExclude['geometry'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')')) {
                         $bExclude = true;
                     }
                 }
                 sql_free_result($rsExclude);
                 if ($bExclude == false) {
                     sql("INSERT INTO `cache_npa_areas` (`cache_id`, `npa_id`, `calculated`)\n                            VALUES ('&1', '&2', 1) ON DUPLICATE KEY UPDATE `calculated`=1", $rCache['cache_id'], $rLayers['id']);
                 }
             }
         }
         sql_free_result($rsLayers);
         sql("UPDATE `caches` SET `need_npa_recalc`=0 WHERE `cache_id`='&1'", $rCache['cache_id']);
     }
     sql_free_result($rsCache);
 }
开发者ID:kirstenko,项目名称:oc-server3,代码行数:27,代码来源:cache_npa_areas.class.php

示例9: plug_tags

function plug_tags($p, $o)
{
    req('mod,spe');
    if ($_GET['sources']) {
        $r = sql('mail', 'qda', 'k', '');
        $go = 'source';
        //source
        foreach ($r as $k => $v) {
            if ($k != 'mail' && trim($k)) {
                $reb[preplink($k)] += 1;
            }
        }
    } else {
        $cat = $p ? $p : 'tag';
        //$reb=tags_list($cat);
        $ra = sql('idtag,idart', 'qdta', 'k', '');
        arsort($ra);
        $rb = sql('id,tag', 'qdt', 'kv', 'cat="' . $cat . '"');
        arsort($ra);
        foreach ($ra as $k => $v) {
            if ($rb[$k]) {
                $reb[$rb[$k]] = $v;
            }
        }
    }
    if ($o) {
        $ret = tags_cloud($reb, 12, 27, ' ', $cat);
    } else {
        $ret = tg_list($reb, $go);
    }
    return divc('txtcadr', count($reb) . ' ' . ($p ? $p : 'Tags')) . $ret;
}
开发者ID:philum,项目名称:cms,代码行数:32,代码来源:tags.php

示例10: run

 public function run()
 {
     $rsDuplicatePic = sql('SELECT `object_id`, `title`
          FROM `pictures`
          WHERE `object_type`=1
          GROUP BY `object_id`, `title`
          HAVING COUNT(*) > 1');
     while ($rDuplicatePic = sql_fetch_assoc($rsDuplicatePic)) {
         $rsInstances = sql(" SELECT `pictures`.`id` `picid`, `cache_logs`.`cache_id` `cache_id`\n                 FROM `pictures`\n                 LEFT JOIN `cache_logs` ON `cache_logs`.`id` = `pictures`.`object_id`\n                 WHERE `pictures`.`object_type`=1 AND `pictures`.`object_id`='&1' AND `pictures`.`title`='&2'\n                 ORDER BY `pictures`.`date_created`", $rDuplicatePic['object_id'], $rDuplicatePic['title']);
         $instances = sql_fetch_assoc_table($rsInstances);
         foreach ($instances as &$instance) {
             $instance['pic'] = new picture($instance['picid']);
             $instance['filesize'] = @filesize($instance['pic']->getFilename());
         }
         $countInstances = count($instances);
         for ($n = 1; $n < $countInstances; ++$n) {
             if ($instances[$n]['filesize'] !== false) {
                 // ensure that pic is stored locally
                 for ($nn = $n - 1; $nn >= 0; --$nn) {
                     if ($instances[$nn]['filesize'] === $instances[$n]['filesize']) {
                         if (file_get_contents($instances[$nn]['pic']->getFilename()) == file_get_contents($instances[$n]['pic']->getFilename())) {
                             $picture = $instances[$n]['pic'];
                             echo 'deleting duplicate picture ' . $picture->getPictureId() . ' ("' . $picture->getTitle() . '")' . ' from log ' . $rDuplicatePic['object_id'] . ' of cache ' . $instances[$n]['cache_id'] . "\n";
                             $picture->delete(false);
                             $instances[$n]['filesize'] = false;
                             break;
                         }
                     }
                 }
             }
         }
     }
     sql_free_result($rsDuplicatePic);
 }
开发者ID:kratenko,项目名称:oc-server3,代码行数:34,代码来源:picture_cleanup.class.php

示例11: run

 function run()
 {
     db_connect();
     $rsCache = sql("SELECT `cache_id`, `latitude`, `longitude` FROM `caches` WHERE `need_npa_recalc`=1");
     while ($rCache = mysql_fetch_assoc($rsCache)) {
         $sql = sql("DELETE FROM `cache_npa_areas` WHERE `cache_id`='&1' AND `calculated`=1", $rCache['cache_id']);
         mysql_query($sql);
         // Natura 2000
         $rsLayers = sql("SELECT `id`, AsText(`shape`) AS `geometry` FROM `npa_areas` WHERE WITHIN(GeomFromText('&1'), `shape`)", 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
         while ($rLayers = mysql_fetch_assoc($rsLayers)) {
             if (gis::ptInLineRing($rLayers['geometry'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')')) {
                 $sql = sql("INSERT INTO `cache_npa_areas` (`cache_id`, `npa_id`, `calculated`) VALUES ('&1', '&2', 1) ON DUPLICATE KEY UPDATE `calculated`=1", $rCache['cache_id'], $rLayers['id']);
                 mysql_query($sql);
             }
         }
         mysql_free_result($rsLayers);
         // Parki PL
         $rsLayers = sql("SELECT `id`, AsText(`shape`) AS `geometry` FROM `parkipl` WHERE WITHIN(GeomFromText('&1'), `shape`)", 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
         while ($rLayers = mysql_fetch_assoc($rsLayers)) {
             if (gis::ptInLineRing($rLayers['geometry'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')')) {
                 $sql = sql("INSERT INTO `cache_npa_areas` (`cache_id`, `parki_id`, `calculated`) VALUES ('&1', '&2', 1) ON DUPLICATE KEY UPDATE `calculated`=1", $rCache['cache_id'], $rLayers['id']);
                 mysql_query($sql);
             }
         }
         mysql_free_result($rsLayers);
         // End of Parki PL
         $sql = sql("UPDATE `caches` SET `need_npa_recalc`=0 WHERE `cache_id`='&1'", $rCache['cache_id']);
         mysql_query($sql);
     }
     mysql_free_result($rsCache);
     db_disconnect();
 }
开发者ID:pawelzielak,项目名称:opencaching-pl,代码行数:32,代码来源:cache_npa_areas.class.php

示例12: resetDBData

function resetDBData() {
    $resetData = array(
        'users' => array(
            array(
                'uid' => 1,
                'username' => 'jonathan',
                'password' => 'password',
                'profile' => 'The best web developer EVAR!',
            ),
        ),
        'posts' => array(
            array(
                'pid' => 1,
                'uid' => 1,
                'content' => 'I think I rock alot',
            )
        )
    );
    foreach ($resetData as $table => $data) {
        foreach ($data as $row) {
            $columns = implode(',', array_keys($row));
            $values = implode(',', array_map('hackSQLEncode', array_values($row)));
            sql("INSERT INTO {$table} ({$columns}) VALUES ({$values});");
        }
    }
}
开发者ID:JonLoesch,项目名称:security,代码行数:26,代码来源:reset.php

示例13: run

 public function run()
 {
     // cleanup XML session data
     sql_temp_table('tmpsessiondata');
     sql('CREATE TEMPORARY TABLE &tmpsessiondata ENGINE=MEMORY
          SELECT DISTINCT `xmlsession_data`.`session_id` FROM `xmlsession_data`
          LEFT JOIN `xmlsession` ON `xmlsession`.`id`=`xmlsession_data`.`session_id`
          WHERE `xmlsession`.`id` IS NULL');
     $count = sql_value('SELECT COUNT(*) FROM `xmlsession_data`
          WHERE `session_id` IN (SELECT `session_id` FROM &tmpsessiondata)', 0);
     if ($count) {
         sql("DELETE FROM `xmlsession_data`\n                 WHERE `session_id` IN (SELECT `session_id` FROM &tmpsessiondata)");
         echo 'orphan_cleanup: dropped ' . $count . " record(s) from xmlsession_data\n";
     }
     sql_drop_temp_table('tmpsessiondata');
     // cleanup map data
     sql_temp_table('tmpsessiondata');
     sql('CREATE TEMPORARY TABLE &tmpsessiondata ENGINE=MEMORY
          SELECT DISTINCT `map2_data`.`result_id` FROM `map2_data`
          LEFT JOIN `map2_result` ON `map2_result`.`result_id`=`map2_data`.`result_id`
          WHERE `map2_result`.`result_id` IS NULL');
     $count = sql_value("SELECT COUNT(*) FROM `map2_data`\n             WHERE `result_id` IN (SELECT `result_id` FROM &tmpsessiondata)", 0);
     if ($count) {
         sql("DELETE FROM `map2_data`\n                 WHERE `result_id` IN (SELECT `result_id` FROM &tmpsessiondata)");
         echo 'orphan_cleanup: dropped ' . $count . " record(s) from map2_data\n";
     }
     sql_drop_temp_table('tmpsessiondata');
 }
开发者ID:kratenko,项目名称:oc-server3,代码行数:28,代码来源:orphan_cleanup.class.php

示例14: getAttrbutesListArrayInternal

 public static function getAttrbutesListArrayInternal($cacheId, $bOnlySelectable, $firstLetterUppercase)
 {
     global $opt;
     $attributes = array();
     $rsAttrGroup = sql("SELECT `attribute_groups`.`id`,\n\t\t             IFNULL(`tt1`.`text`, `attribute_groups`.`name`) AS `name`,\n\t\t             IFNULL(`tt2`.`text`, `attribute_categories`.`name`) AS `category`,\n\t\t             `attribute_categories`.`color`\n\t\t\tFROM `attribute_groups`\n\t\t\tINNER JOIN `attribute_categories` \n\t\t\t    ON `attribute_groups`.`category_id`=`attribute_categories`.`id`\n\t\t\tLEFT JOIN `sys_trans` AS `t1` \n\t\t\t    ON `attribute_groups`.`trans_id`=`t1`.`id` \n\t\t\t    AND `attribute_groups`.`name`=`t1`.`text`\n\t\t\tLEFT JOIN `sys_trans_text` AS `tt1` \n\t\t\t    ON `t1`.`id`=`tt1`.`trans_id` \n\t\t\t    AND `tt1`.`lang`='&1'\n\t\t\tLEFT JOIN `sys_trans` AS `t2` \n\t\t\t    ON `attribute_categories`.`trans_id`=`t2`.`id` \n\t\t\t    AND `attribute_categories`.`name`=`t2`.`text`\n\t\t\tLEFT JOIN `sys_trans_text` AS `tt2` \n\t\t\t    ON `t2`.`id`=`tt2`.`trans_id` \n\t\t\t    AND `tt2`.`lang`='&1'\n\t\t\tORDER BY `attribute_groups`.`id` ASC", $opt['template']['locale']);
     while ($rAttrGroup = sql_fetch_assoc($rsAttrGroup)) {
         $attr = array();
         $bFirst = true;
         $bSearchGroupDefault = false;
         if ($cacheId == 0) {
             $sAddWhereSql = '';
             if ($bOnlySelectable == true) {
                 $sAddWhereSql .= ' AND `cache_attrib`.`selectable`=1';
             }
             $rsAttr = sql("SELECT `cache_attrib`.`id`, \n                            IFNULL(`tt1`.`text`, `cache_attrib`.`name`) AS `name`,\n\t\t\t\t\t\t\tIFNULL(`tt2`.`text`, `cache_attrib`.`html_desc`) AS `html_desc`,\n\t\t\t\t\t\t\t`cache_attrib`.`icon`, `cache_attrib`.`search_default`\n\t\t\t\t\tFROM `cache_attrib`\n\t\t\t\t\tLEFT JOIN `sys_trans` AS `t1` \n\t\t\t\t\t    ON `cache_attrib`.`trans_id`=`t1`.`id` \n\t\t\t\t\t    AND `cache_attrib`.`name`=`t1`.`text`\n\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt1` \n\t\t\t\t\t    ON `t1`.`id`=`tt1`.`trans_id` \n\t\t\t\t\t    AND `tt1`.`lang`='&1'\n\t\t\t\t\tLEFT JOIN `sys_trans` AS `t2` \n\t\t\t\t\t    ON `cache_attrib`.`html_desc_trans_id`=`t2`.`id`\n\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt2` \n\t\t\t\t\t    ON `t2`.`id`=`tt2`.`trans_id` \n\t\t\t\t\t    AND `tt2`.`lang`='&1'\n\t\t\t\t\tWHERE `cache_attrib`.`group_id`='&2'" . $sAddWhereSql . "\n\t\t\t\t\tAND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1\n\t\t\t\t\tORDER BY `cache_attrib`.`group_id` ASC", $opt['template']['locale'], $rAttrGroup['id']);
         } else {
             $rsAttr = sql("SELECT `cache_attrib`.`id`, \n                            IFNULL(`tt1`.`text`, `cache_attrib`.`name`) AS `name`,\n\t\t\t\t\t\t\tIFNULL(`tt2`.`text`, `cache_attrib`.`html_desc`) AS `html_desc`,\n\t\t\t\t\t\t\t`cache_attrib`.`icon`, `cache_attrib`.`search_default`\n\t\t\t\t\tFROM `caches_attributes`\n\t\t\t\t\tINNER JOIN `cache_attrib` \n\t\t\t\t\t    ON `caches_attributes`.`attrib_id`=`cache_attrib`.`id`\n\t\t\t\t\tLEFT JOIN `sys_trans` AS `t1` \n\t\t\t\t\t    ON `cache_attrib`.`trans_id`=`t1`.`id` \n\t\t\t\t\t    AND `cache_attrib`.`name`=`t1`.`text`\n\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt1` \n\t\t\t\t\t    ON `t1`.`id`=`tt1`.`trans_id` \n\t\t\t\t\t    AND `tt1`.`lang`='&2'\n\t\t\t\t\tLEFT JOIN `sys_trans` AS `t2` \n\t\t\t\t\t    ON `cache_attrib`.`html_desc_trans_id`=`t2`.`id`\n\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt2` \n\t\t\t\t\t    ON `t2`.`id`=`tt2`.`trans_id`\n\t\t\t\t\t    AND `tt2`.`lang`='&2'\n\t\t\t\t\tWHERE `caches_attributes`.`cache_id`='&1' \n\t\t\t\t\tAND `cache_attrib`.`group_id`='&3'\n\t\t\t\t\tAND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1\n\t\t\t\t\tORDER BY `cache_attrib`.`group_id` ASC", $cacheId, $opt['template']['locale'], $rAttrGroup['id']);
         }
         while ($rAttr = sql_fetch_assoc($rsAttr)) {
             if ($firstLetterUppercase) {
                 $rAttr['name'] = mb_strtoupper(mb_substr($rAttr['name'], 0, 1)) . mb_substr($rAttr['name'], 1);
             }
             $attr[] = $rAttr;
             if ($rAttr['search_default']) {
                 $bSearchGroupDefault = true;
             }
         }
         sql_free_result($rsAttr);
         if (count($attr) > 0) {
             $attributes[] = array('id' => $rAttrGroup['id'], 'name' => $rAttrGroup['name'], 'color' => $rAttrGroup['color'], 'category' => $rAttrGroup['category'], 'search_default' => $bSearchGroupDefault, 'attr' => $attr);
         }
     }
     sql_free_result($rsAttrGroup);
     return $attributes;
 }
开发者ID:kirstenko,项目名称:oc-server3,代码行数:35,代码来源:attribute.class.php

示例15: searchUser

function searchUser()
{
    global $tpl;
    $username = isset($_REQUEST['username']) ? $_REQUEST['username'] : '';
    $msg = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : '';
    $tpl->assign('username', $username);
    $tpl->assign('msg', $msg);
    $rs = sql("SELECT `user_id`, `username`, `email`, `date_created`, `last_modified`, `is_active_flag`, `activation_code`, `first_name`, `last_name` FROM `user` WHERE `username`='&1' OR `email`='&1'", $username);
    $r = sql_fetch_assoc($rs);
    sql_free_result($rs);
    if ($r == false) {
        $tpl->assign('error', 'userunknown');
        $tpl->display();
    }
    $tpl->assign('showdetails', true);
    $r['hidden'] = sql_value("SELECT COUNT(*) FROM `caches` WHERE `user_id`='&1'", 0, $r['user_id']);
    $r['hidden_active'] = sql_value("SELECT COUNT(*) FROM `caches` WHERE `user_id`='&1' AND `status`=1", 0, $r['user_id']);
    $r['logentries'] = sql_value("SELECT COUNT(*) FROM `cache_logs` WHERE `user_id`='&1'", 0, $r['user_id']);
    $r['last_known_login'] = sql_value("SELECT MAX(`last_login`) FROM `sys_sessions` WHERE `user_id`='&1'", 0, $r['user_id']);
    $tpl->assign('user', $r);
    $user = new user($r['user_id']);
    if (!$user->exist()) {
        $tpl->error(ERROR_UNKNOWN);
    }
    $tpl->assign('candisable', $user->canDisable());
    $tpl->assign('candelete', $user->canDelete());
    $tpl->display();
}
开发者ID:RH-Code,项目名称:opencaching,代码行数:28,代码来源:adminuser.php


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