niushop使用了thinkphp的数据库操作原理,用户可以使用thinkphp的数据库操作,但是niushop针对数据库操作整体进行了封装,数据查询更加方便,所以建议用户使用niushop专门封装的数据库操作便于整体管理。
model(‘help’)->getInfo([ [‘id’, ‘=’, $help_id], [‘site_id’, ‘=’, s i t e i d ] ] , ′ i d , t i t l e , c o n t e n t , c l a s s i d , c l a s s n a m e , s o r t , l i n k a d d r e s s , c r e a t e t i m e , m o d i f y t i m e ′ ) ; 查询列表 g e t L i s t ( site_id] ], 'id, title, content, class_id, class_name, sort, link_address, create_time, modify_time'); 查询列表getList( siteid]],′id,title,content,classid,classname,sort,linkaddress,createtime,modifytime′);查询列表getList(condition = [], $field = true, $order = ‘’, $alias = ‘a’, $join = [], $group = ‘’, $limit = null)
model(‘help’)->getList($condition, $field, $order, ‘’, ‘’, ‘’, l i m i t ) ; 查询分页列表 p a g e L i s t ( limit); 查询分页列表pageList( limit);查询分页列表pageList(condition = [], $field = true, $order = ‘’, $page = 1, $list_rows = PAGE_LIST_ROWS, $alias = ‘a’, $join = [], $group = null, $limit = null)
model(‘help’)->pageList($condition, $field, $order, $page, $page_size);
查询视图,按照thinkphp视图查询方法:
public function getApplyDetail($condition)
{
$field = 'nsa.apply_id, nsa.site_id,nsa.website_id, nsa.member_id, nsa.username, nsa.cert_id, nsa.shop_name, nsa.apply_state,
nsa.apply_message, nsa.apply_year, nsa.category_name, nsa.category_id, nsa.group_name, nsa.group_id,
nsa.paying_money_certificate, nsa.paying_money_certificate_explain, nsa.paying_deposit, nsa.paying_apply,
nsa.paying_amount, nsa.create_time, nsa.audit_time, nsa.finish_time,
nsc.cert_id, nsc.cert_type, nsc.company_name, nsc.company_province_id, nsc.company_city_id, nsc.company_district_id,
nsc.company_address, nsc.contacts_name, nsc.contacts_mobile, nsc.contacts_card_no, nsc.contacts_card_electronic_1,
nsc.contacts_card_electronic_2, nsc.contacts_card_electronic_3, nsc.business_licence_number,
nsc.business_licence_number_electronic, nsc.business_sphere, nsc.taxpayer_id, nsc.general_taxpayer,
nsc.tax_registration_certificate, nsc.tax_registration_certificate_electronic, nsc.bank_account_name,
nsc.bank_account_number, nsc.bank_name, nsc.bank_address, nsc.bank_code, nsc.bank_type, nsc.settlement_bank_account_name,
nsc.settlement_bank_account_number, nsc.settlement_bank_name, nsc.settlement_bank_address,nsc.company_full_address,
w.site_area_name';
$alias = 'nsa';
$join = [
[
'shop_cert nsc',
'nsa.cert_id = nsc.cert_id',
'left'
],
[
'website w',
'w.site_id = nsa.website_id',
'left'
],
];
$info = model('shop_apply')->getInfo($condition, $field, $alias, $join);
return $this->success($info);
}
查询第一条数据getFirstData($condition, $order)
获取查询数据的数量getCount($condition)
获取查询字段和getSum($condition, $field)
获取查询字段最大值getMax($condition, $field)
获取查询字段最小值getMin($condition, $field)
数据添加
niushop数据添加使用add方法,例如:
/**
数据修改,使用update方法,传入修改条件
/**
数据删除,使用delete方法
/**