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


PHP mysql::query方法代码示例

本文整理汇总了PHP中mysql::query方法的典型用法代码示例。如果您正苦于以下问题:PHP mysql::query方法的具体用法?PHP mysql::query怎么用?PHP mysql::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mysql的用法示例。


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

示例1: extraerTags

function extraerTags($ID)
{
    global $db_source, $prefix;
    /*
     * Importación de Categorías
     */
    $m = new mysql();
    #SQL: extrae los tags de WP para el ID del post que se pase como parámetro.
    $m->query("SELECT t.term_id,t.slug,t.name,tr.object_id FROM {$db_source}.wp_terms as t \n\n\t\tinner join {$db_source}.wp_term_taxonomy as tt on tt.term_id = t.term_id \n\n\t\tinner join {$db_source}.wp_term_relationships as tr on tr.term_taxonomy_id = t.term_id \n\n\t\tWHERE tt.taxonomy = 'category' and tr.object_id={$ID} \n\n\t\t");
    $sql_tags = "INSERT INTO " . $prefix . "tags(tag_id,tag,urlfriendly) VALUES ";
    $insertTags = false;
    $sql_relation = "INSERT INTO " . $prefix . "tags_rel(tag_id,post_id) VALUES ";
    $hasTags = false;
    /*
     * Para cada tag del post extraido de WP
     * 1.- Revisar si existe, si no, lo inserta.
     */
    if ($m->total() > 0) {
        while ($m->fetch()) {
            $m2 = new mysql();
            /*
             * Si no existe tag, lo insertamos.
             */
            $m2->query("SELECT * FROM " . $prefix . "tags WHERE tag_id=" . $m->sql_quote($m->row['term_id']) . "");
            if (!$m2->fetch()) {
                $sql_tags .= "(" . $m->sql_quote($m->row['term_id']) . "," . "'" . $m->sql_quote($m->row['name']) . "'," . "'" . $m->sql_quote($m->row['slug']) . "'" . "), ";
                $insertTags = true;
            }
            /*
             * Buscamos si existe la relacion entre el tag y el post, si no, la creamos.
             */
            $m2->query("SELECT * FROM " . $prefix . "tags_rel WHERE tag_id=" . $m->sql_quote($m->row['term_id']) . " AND post_id=" . $ID);
            if (!$m2->fetch()) {
                $sql_relation .= " (" . $m->sql_quote($m->row['term_id']) . "," . $m->sql_quote($ID) . "), ";
                $hasTags = true;
            }
        }
        //while
    } else {
        //no tiene tags, entonces lo ponemos bajo el tag 'general'. Generalmente id=1
        $sql_relation .= " (1," . $m->sql_quote($ID) . "), ";
        $hasTags = true;
    }
    //if
    if ($insertTags) {
        $sql_tags = substr($sql_tags, 0, -2) . ';';
        $m->query($sql_tags);
    }
    if ($hasTags) {
        $sql_relation = substr($sql_relation, 0, -2) . ';';
        $m->query($sql_relation);
    }
}
开发者ID:ravenlp,项目名称:CodiceCMS,代码行数:53,代码来源:index.php

示例2: get_slider

 function get_slider($limit, $name_file)
 {
     $sql = 'select * from splash where status=1 order by sort limit ' . $limit;
     $result = mysql::query($sql, 0);
     // выполняем tpl
     return system::show_tpl(array('splash' => $result), $name_file);
 }
开发者ID:AngelWayfarer,项目名称:prizvanie,代码行数:7,代码来源:splash.class.php

示例3: indexAction

 /**
  * выводим материал
  */
 function indexAction()
 {
     $_sql = 'select * from ' . $this->tablename . ' where status=1 order by sort';
     // выполняем запрос + при необходимости выводим сам запрос
     $result = mysql::query($_sql, 0);
     return system::show_tpl(array('result' => $result, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/index.php');
 }
开发者ID:AngelWayfarer,项目名称:prizvanie,代码行数:10,代码来源:seoController.php

示例4: _view

 /**
  * Zeigt die Einträge an
  *
  * @param integer $max_entries_pp Anzahl Einträge pro Seite
  */
 private function _view($max_entries_pp)
 {
     $this->_tplfile = 'gbook.tpl';
     $gbook_array = array();
     if (isset($this->_gpc['GET']['page']) && is_numeric($this->_gpc['GET']['page']) && $this->_gpc['GET']['page'] > 0) {
         $page = $this->_gpc['GET']['page'];
     } else {
         $page = 1;
     }
     $gbook_array = $this->_msbox->getEntries($max_entries_pp, $page, 'DESC', 'ASC', $this->_timeformat);
     $this->_mysql->query('SELECT COUNT(*) as many FROM `gbook` WHERE `gbook_ref_ID` = \'0\'');
     $entries = $this->_mysql->fetcharray('num');
     $this->_mysql->query('SELECT COUNT(*) as many FROM `gbook` WHERE `gbook_ref_ID` != \'0\'');
     $comments = $this->_mysql->fetcharray('num');
     $pagesnav_array = Page::get_static_pagesnav_array($entries[0], $max_entries_pp, $this->_gpc['GET']);
     //Inhalt parsen (Smilies) und an Smarty-Array übergeben
     foreach ($gbook_array as $key => $value) {
         $gbook_array[$key] = array('ID' => $value['gbook_ID'], 'title' => htmlentities($value['gbook_title']), 'content' => $this->_smilie->show_smilie(nl2br(htmlentities($value['gbook_content'])), $this->_mysql), 'name' => htmlentities($value['gbook_name']), 'time' => $value['gbook_time'], 'email' => htmlentities($value['gbook_email']), 'hp' => htmlentities($value['gbook_hp']), 'number_of_comments' => $value['number_of_comments']);
         $count = 0;
         //Kommentare durchackern
         foreach ($value['comments'] as $ckey => $cvalue) {
             $gbook_array[$key]['comments'][$ckey] = array('ID' => $cvalue['gbook_ID'], 'title' => htmlentities($cvalue['gbook_title']), 'content' => $this->_smilie->show_smilie(nl2br(htmlentities($cvalue['gbook_content'])), $this->_mysql), 'name' => htmlentities($cvalue['gbook_name']), 'time' => $cvalue['gbook_time'], 'email' => htmlentities($cvalue['gbook_email']), 'hp' => htmlentities($cvalue['gbook_hp']));
             $count++;
         }
     }
     $this->_smarty->assign('gbook', $gbook_array);
     $this->_smarty->assign('pages', $pagesnav_array);
     $this->_smarty->assign('entries', $entries[0]);
     $this->_smarty->assign('comments', $comments[0]);
 }
开发者ID:BackupTheBerlios,项目名称:jclubcms,代码行数:35,代码来源:gbook.class.php

示例5: query

 private static function query($arrSea, $isFind)
 {
     $model = get_called_class();
     $limit = isset($arrSea["limit"]) ? "LIMIT " . $arrSea["limit"] : "";
     if (!$isFind) {
         $limit = "LIMIT 1";
     }
     $order = isset($arrSea["order"]) ? "ORDER BY " . $arrSea["order"] : "";
     $where = isset($arrSea["where"]) ? "WHERE " . $arrSea["where"] : "";
     $sql = "SELECT * FROM `{$model}` {$where} {$order} {$limit}";
     $res = mysql::query($sql);
     if ($res) {
         $findArr = array();
         for ($i = 0; $i !== $res->num_rows; $i++) {
             $res->data_seek($i);
             $row = $res->fetch_assoc();
             $class = new $model(false);
             foreach ($class as $key => &$val) {
                 $val = $row[$key];
             }
             if (!$isFind) {
                 return $class;
             }
             array_push($findArr, $class);
         }
         return $findArr;
     } else {
         return false;
     }
 }
开发者ID:WanSpi,项目名称:wcms,代码行数:30,代码来源:model.php

示例6: process_message

function process_message($msg)
{
    echo "\n############ 信息日志开始 ###############\n";
    echo date('Y-m-d H:i:s') . "=====" . $msg->body;
    echo "\n############ 信息日志结束 ###############\n";
    //执行SQL语句
    $db_config = C("DB_CONFIG");
    $dbConn = new mysql();
    $dbConn->connect($db_config["master1"][0], $db_config["master1"][1], $db_config["master1"][2], '');
    $dbConn->select_db($db_config["master1"][4]);
    $sql = $msg->body;
    $query = $dbConn->query($sql);
    if (!$query) {
        Log::write($sql, Log::ERR);
    } else {
        echo date('Y-m-d H:i:s') . '===== [ok] ', '=====', $sql, "\n";
        //确认消费OK
        $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
    }
    $dbConn->close();
    // Send a message with the string "quit" to cancel the consumer.
    if ($msg->body === 'quit') {
        $msg->delivery_info['channel']->basic_cancel($msg->delivery_info['consumer_tag']);
    }
}
开发者ID:ohjack,项目名称:newErp,代码行数:25,代码来源:notice_power_subscribe.php

示例7: query

 function query($query)
 {
     $mt = $this->getmicrotime();
     $return = parent::query($query);
     $time = $this->getmicrotime() - $mt;
     $r = mysql_query('EXPLAIN ' . $query, $this->mysql_link);
     $explain = $this->result_to_data($r);
     $ex_echo .= '<table border="1">';
     foreach ($explain as $key => $value) {
         if ($key == 0) {
             $ex_echo .= '<tr>';
             foreach ($value as $key2 => $value2) {
                 $ex_echo .= '<td>' . $key2 . '</td>';
             }
             $ex_echo .= '</tr>';
         }
         $ex_echo .= '<tr>';
         foreach ($value as $key2 => $value2) {
             $ex_echo .= '<td>' . $value2 . '</td>';
         }
         $ex_echo .= '</tr>';
     }
     $ex_echo .= '</table>';
     echo '<tr><td>' . $query . '</td><td>' . $ex_echo . '</td><td>' . $time . '</td></tr>';
     return $return;
 }
开发者ID:southern-wind,项目名称:wind,代码行数:26,代码来源:mysql.php

示例8: query

 public function query($sql)
 {
     if ($this->params && strtoupper(substr($sql, 0, 6)) == 'SELECT') {
         parent::getInstance_slave($this->params);
         return parent::query($sql, self::$instance_slave->db_link);
     } else {
         return parent::query($sql);
     }
 }
开发者ID:rainbow88,项目名称:hummel,代码行数:9,代码来源:mysql_slave.class.php

示例9: indexAction

 /**
  * отображаем весь список материалов
  */
 function indexAction()
 {
     $this->table_name = $_GET['tablename'];
     // строим запрос
     $_sql = 'SELECT * FROM ' . $this->table_name . ' where id>0 ' . general::get_status_for_filter($_GET['tablename']) . ' order by sort';
     // выполняем запрос + при необходимости выводим сам запрос
     $result = mysql::query($_sql, 0);
     return system::show_tpl(array('result' => $result, 'msg' => $this->msg, '_status' => isset($_POST['status']) ? $_POST['status'] : 2, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/index.php');
 }
开发者ID:AngelWayfarer,项目名称:prizvanie,代码行数:12,代码来源:onelevelController.php

示例10: get_otvet

 static function get_otvet($name_file, $id_parent)
 {
     // выбираем вопрос
     $_sql = "SELECT\n\t\t\tvoting.id,\n\t\t\tvoting.id_parent,\n\t\t\tvoting.`text`,\n\t\t\tvoting.kolvo,\n\t\t\tROUND(voting.kolvo*100/voting.summa) as summa\n\t\t\tFROM\n\t\t\t\tvoting\n\t\t\tjoin (select SUM(voting.kolvo) as summa from voting WHERE voting.status = 1 and voting.id_parent = " . intval($id_parent) . ") as voting\n\t\t\tWHERE\n\t\t\t\tvoting.status = 1 and\n\t\t\t\tvoting.id_parent = " . intval($id_parent) . "\n\t\t\torder by voting.sort\n\t\t\t";
     // выполняем запрос + при необходимости выводим сам запрос
     $result = mysql::query($_sql, 0);
     // выполняем tpl
     return system::show_tpl(array('otvet' => $result), $name_file);
 }
开发者ID:AngelWayfarer,项目名称:prizvanie,代码行数:9,代码来源:voting.class.php

示例11: testAction

 public function testAction()
 {
     $conn = new mysql();
     $conn->open(getSqlConfig('main'));
     $sql = "select * from userinfo";
     $result = $conn->query_select($sql);
     var_dump($result);
     $r1 = $conn->query($sql);
     echo Carbon\Carbon::today();
     return false;
 }
开发者ID:xiaofang520,项目名称:agency,代码行数:11,代码来源:Index.php

示例12: destroy

 /**
  * Destroys a record in the table
  *
  * @param integer $id ()
  * @access public
  */
 function destroy($id)
 {
     $sql = "DELETE FROM {$this->table} WHERE {$this->primary_key} = {$id}";
     $result = $this->db->query($sql);
     if ($this->debug) {
         echo '<p><strong>Destroy SQL:</strong> ' . $sql . '</p>';
         if ($this->db->isError()) {
             echo $this->db->getErrorMsg();
             return false;
         }
     }
     return true;
 }
开发者ID:laiello,项目名称:bitcero-modules,代码行数:19,代码来源:class.table.php

示例13: editAction

 /**
  * редактирование настроек
  */
 function editAction()
 {
     if ($_POST) {
         // записываем в базу
         forms::multy_update_form_all_records($this->tablename, 'zna', 0);
         $this->msg = general::messages(1, v::getI18n('backend_after_save'));
     }
     // строим запрос
     $_sql = 'SELECT * FROM ' . $this->tablename . ' where status=1 order by sort';
     // выполняем запрос + при необходимости выводим сам запрос
     $result = mysql::query($_sql, 0);
     return system::show_tpl(array('result' => $result, 'msg' => $this->msg, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/edit.php');
 }
开发者ID:AngelWayfarer,项目名称:prizvanie,代码行数:16,代码来源:configController.php

示例14: indexAction

 /**
  * отображаем весь список материалов
  */
 function indexAction()
 {
     // если перешли по get ссылке из меню
     //if(isset($_GET['status'])) { $_POST['status']=$_GET['status']; }
     if (isset($_POST['status'])) {
         $_SESSION['status'] = $_POST['status'];
     }
     // строим запрос
     $_sql = 'SELECT * FROM ' . $this->tablename . ' where id>0 ' . general::get_status_for_filter($this->tablename) . ' order by id desc';
     // выполняем запрос + при необходимости выводим сам запрос
     $result = mysql::query($_sql, 0);
     return system::show_tpl(array('result' => $result, 'msg' => $this->msg, '_status' => isset($_POST['status']) ? $_POST['status'] : 2, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/index.php');
 }
开发者ID:AngelWayfarer,项目名称:prizvanie,代码行数:16,代码来源:gbController.php

示例15: __construct

 private function __construct()
 {
     //-----------需要页面显示调试信息,	注释掉下面两行即可---
     set_error_handler(array("Core", 'appError'));
     set_exception_handler(array("Core", 'appException'));
     date_default_timezone_set("Asia/Shanghai");
     if (version_compare(PHP_VERSION, '5.4.0', '<')) {
         @set_magic_quotes_runtime(0);
         define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc() ? True : False);
     }
     //设置根目录
     if (!defined('WEB_PATH')) {
         define("WEB_PATH", "/data/web/notice.valsun.cn/");
     }
     //加载通用检测方法
     include_once WEB_PATH . "lib/common.php";
     //加载全局配置信息
     C(include_once WEB_PATH . 'conf/common.php');
     include_once WEB_PATH . "lib/auth.php";
     //鉴权
     //Auth::setAccess(include WEB_PATH.'conf/access.php');
     include_once WEB_PATH . "lib/log.php";
     include_once WEB_PATH . "lib/page.php";
     include_once WEB_PATH . "lib/authuser.class.php";
     include_once WEB_PATH . "lib/opensys_functions.php";
     //加载数据接口层及所需支撑
     include_once WEB_PATH . "lib/service/http.php";
     //网络接口
     include_once WEB_PATH . "lib/functions.php";
     include_once WEB_PATH . "lib/cache/cache.php";
     //memcache
     if (C("DATAGATE") == "db") {
         $db = C("DB_TYPE");
         include_once WEB_PATH . "lib/db/" . $db . ".php";
         //db直连
         if ($db == "mysql") {
             global $dbConn;
             $db_config = C("DB_CONFIG");
             $dbConn = new mysql();
             $dbConn->connect($db_config["master1"][0], $db_config["master1"][1], $db_config["master1"][2]);
             $dbConn->select_db($db_config["master1"][4]);
             $dbConn->query('set names utf8');
         }
         if ($db == "mongodb") {
             //.......
         }
     }
     //自动加载类
     spl_autoload_register(array('Core', 'autoload'));
 }
开发者ID:ohjack,项目名称:newErp,代码行数:50,代码来源:framework.php


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