Ecshopx开发之如何取出数据库中的数据(No.2)
这里简单说明下如何查询数据
代码路径:/src/OrdersBundle/Http/FrontApi/V1/Action/WxappOrder.php
先在文件内引入
use KaquanBundle\Entities\MemberCard;
$memberCardRepository = app('registry')->getManager('default')->getRepository(MemberCard::class);### MemberCard 对应你要查询的表
$memberCardRepository->get($filter); ### $filter为查询的条件 数组
这里我们直接用系统中封装的get去获取
$memberCardRepository = app('registry')->getManager('default')->getRepository(MemberCard::class);
$memberCardResult = $memberCardRepository->get(['company_id' => $authInfo['company_id']]);
下面也可以用标准写法去操作
$memberCardRepository = app('registry')->getManager('default')->getRepository(MemberCard::class);### MemberCard 对应你要查询的表
$memberCardRepository->findBy($filter); ### $filter为查询的条件 数组
例子如:
$memberCardRepository = app('registry')->getManager('default')->getRepository(MemberCard::class);
$memberCardResult = $memberCardRepository->findBy(['company_id' => $authInfo['company_id']]);