首页 > 后端开发 > php教程 > 看看这个如何同时调用两个数据表里的不同数据?

看看这个如何同时调用两个数据表里的不同数据?

WBOY
发布: 2016-10-11 14:23:17
原创
1054 人浏览过

这是原来的调用:
$_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
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板