看看這個如何同時調用兩個資料表裡的不同資料?

來源:互聯網
上載者:User
這是原來的調用:
$_G['db']->from('dbpre_subject');
$_G['db']->select('*');
$_G['db']->where('city_id', array(0,$_CITY['aid']));
$_G['db']->where_concat_like('name,subname', "%{$q}%");
$_G['db']->where('status', 1);

現在我要在此基礎之上,在調用dbpre_subject_product_new 這個資料表裡的c_product_price和c_product_content這兩個欄位,,,改怎麼寫,,,先謝謝諸位大神了

//下面是源碼:

!defined('IN_MUDDER') && exit('Access Denied');

$city_id = _get('city_id', null, MF_INT_KEY);
if($city_id>0) {
$citys = $_G['loader']->variable('area');

if(!$city = $citys[$city_id]) redirect('global_area_city_id_invalid');if(!$city['enabled']) redirect('global_area_city_disabled');init_city($city_id);

}

$q = _input('keyword', '', MF_TEXT);
if(($_GET['Pathinfo'] || $_GET['Rewrite']) && $q && $_G['charset'] != 'utf-8' && $_G'cfg') {
$q = charset_convert($q,'utf-8',$_G['charset']);
}
$q = str_replace(array("rn","r","n") ,'', _T($q));

$_G['db']->from('dbpre_subject');
$_G['db']->select('*');
$_G['db']->where('city_id', array(0,$_CITY['aid']));
$_G['db']->where_concat_like('name,subname', "%{$q}%");
$_G['db']->where('status', 1);

$multipage = '';
if($total = $_G['db']->count()) {
$_G['db']->sql_roll_back('from,select,where');
$orderby = array($post['ordersort']=>$post['ordertype']);
$offset = 10;
$start = get_start($_GET['page'], $offset);
$_G['db']->order_by($orderby);
$_G['db']->limit($start, $offset);
$list = $_G['db']->get();
if($total) {
$multipage = mobile_page($total, $offset, $_GET['page'], url("item/mobile/do/search/keyword/$q/page/_PAGE_"));
}
}

//顯示模版
if($_G['in_ajax']) {
include mobile_template('item_list_li');
output();
}

$title = '搜尋產品:'.$q;
include mobile_template('item_list');

回複內容:

這是原來的調用:
$_G['db']->from('dbpre_subject');
$_G['db']->select('*');
$_G['db']->where('city_id', array(0,$_CITY['aid']));
$_G['db']->where_concat_like('name,subname', "%{$q}%");
$_G['db']->where('status', 1);

現在我要在此基礎之上,在調用dbpre_subject_product_new 這個資料表裡的c_product_price和c_product_content這兩個欄位,,,改怎麼寫,,,先謝謝諸位大神了

//下面是源碼:

!defined('IN_MUDDER') && exit('Access Denied');

$city_id = _get('city_id', null, MF_INT_KEY);
if($city_id>0) {
$citys = $_G['loader']->variable('area');

if(!$city = $citys[$city_id]) redirect('global_area_city_id_invalid');if(!$city['enabled']) redirect('global_area_city_disabled');init_city($city_id);

}

$q = _input('keyword', '', MF_TEXT);
if(($_GET['Pathinfo'] || $_GET['Rewrite']) && $q && $_G['charset'] != 'utf-8' && $_G'cfg') {
$q = charset_convert($q,'utf-8',$_G['charset']);
}
$q = str_replace(array("rn","r","n") ,'', _T($q));

$_G['db']->from('dbpre_subject');
$_G['db']->select('*');
$_G['db']->where('city_id', array(0,$_CITY['aid']));
$_G['db']->where_concat_like('name,subname', "%{$q}%");
$_G['db']->where('status', 1);

$multipage = '';
if($total = $_G['db']->count()) {
$_G['db']->sql_roll_back('from,select,where');
$orderby = array($post['ordersort']=>$post['ordertype']);
$offset = 10;
$start = get_start($_GET['page'], $offset);
$_G['db']->order_by($orderby);
$_G['db']->limit($start, $offset);
$list = $_G['db']->get();
if($total) {
$multipage = mobile_page($total, $offset, $_GET['page'], url("item/mobile/do/search/keyword/$q/page/_PAGE_"));
}
}

//顯示模版
if($_G['in_ajax']) {
include mobile_template('item_list_li');
output();
}

$title = '搜尋產品:'.$q;
include mobile_template('item_list');

不知所謂, 你連你們用的什麼PHP架構都不知道, 也不知道用的什麼mysql驅動, 沒人回答得了你, 還請重新命好題再提問吧

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.