首頁 > 後端開發 > php教程 > 看看這個如何同時呼叫兩個資料表裡的不同資料?

看看這個如何同時呼叫兩個資料表裡的不同資料?

WBOY
發布: 2016-10-11 14:23:17
原創
1053 人瀏覽過

這是原來的呼叫:
$_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');

<code>if(!$city = $citys[$city_id]) redirect('global_area_city_id_invalid');
if(!$city['enabled']) redirect('global_area_city_disabled');
init_city($city_id);</code>
登入後複製
登入後複製

}

$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');

<code>if(!$city = $citys[$city_id]) redirect('global_area_city_id_invalid');
if(!$city['enabled']) redirect('global_area_city_disabled');
init_city($city_id);</code>
登入後複製
登入後複製

}

$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驅動, 沒人回答得了你, 還請重新命好題再提問吧

相關標籤:
php
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板