Niushop开源商城数据操作

此前与大家分享了Niushop开源商系统单商户V4的数据库代码,今天,阿牛ger再与大家分享Niushop开源商城V4单商户商城系统的数据库操作。

niushop使用了thinkphp的数据库操作原理,用户可以使用thinkphp的数据库操作,但是niushop针对数据库操作整体进行了封装,数据查询更加方便,所以建议用户使用niushop专门封装的数据库操作便于整体管理。

数据查询
查询单条数据 getInfo($condition, f i e l d ) : field): field):condition:表示传入条件,$field:表示查询字段

model(‘help’)->getInfo([ [‘id’, ‘=’, $help_id], [‘site_id’, ‘=’, $site_id] ], ‘id, title, content, class_id, class_name, sort, link_address, create_time, modify_time’);

查询列表getList($condition = [], $field = true, $order = ‘’, $alias = ‘a’, $join = [], $group = ‘’, $limit = null)

model(‘help’)->getList($condition, $field, $order, ‘’, ‘’, ‘’, $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)

这期阿牛ger主要与大家分享了数据库查询操作,下期阿牛ger继续分享数据库添加、数据库修改、数据库查询这些操作代码,希望阿牛ger的分享能帮助到大家!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值