Home  >  Article  >  Backend Development  >  Take a look at how to call different data in two data tables at the same time?

Take a look at how to call different data in two data tables at the same time?

WBOY
WBOYOriginal
2016-10-11 14:23:171030browse

This is the original call:
$_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);

Now I want to build on this basis and change the two fields c_product_price and c_product_content in the data table called dbpre_subject_product_new. Thank you in advance.

//The following is the source code:

!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_ "));
}
}

//Display template
if($_G['in_ajax']) {
include mobile_template('item_list_li');
output();
}

$title = 'Search for products:'.$q;
include mobile_template('item_list');

Reply content:

This is the original call:
$_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);

Now I want to build on this basis and change the two fields c_product_price and c_product_content in the data table called dbpre_subject_product_new. Thank you in advance.

//The following is the source code:

!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_ "));
}
}

//Display template
if($_G['in_ajax']) {
include mobile_template('item_list_li');
output();
}

$title = 'Search for products:'.$q;
include mobile_template('item_list');

I don’t know, you don’t even know what PHP framework you are using, and you don’t know what mysql driver you are using. No one can answer you, so please rename the question and ask again

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn