当前位置:

微赞微擎服务端SQL增删改查示例

本文最后更新于2019-09-30,已超过 1年没有更新,如果文章内容、图片或者下载资源失效,请留言反馈,我会及时处理,谢谢!

温馨提示:本文共1950个字,读完预计5分钟。

查询单条记录(一维)

        $sns_userInfo = pdo_fetch('select id,openid,honorid,honorids  from ' . tablename('ewei_shop_sns_member') . ' where uniacid=:uniacid and openid=:openid limit 1 ', array(':uniacid' => $_W[‘uniacid’], ':openid' => $openid));

查询多条记录(二维)

            $list = pdo_fetchall('SELECT sr.*,ip.title,ip.desc,ip.thumb,ip.id ipid  FROM ' . tablename('ewei_shop_sns_study_record') . ' sr ' . ' left join ' . tablename('ewei_shop_ip_story') . ' ip on sr.fromid = ip.id ' .  (' WHERE 1 ' . $condition . '  ORDER BY sr.updatetime DESC limit ') . $begin . ',' . $psize2, $params);

返回查询结果值

            $total = pdo_fetchcolumn('SELECT count(1) FROM ' . tablename('ewei_shop_sns_study_record') . (' WHERE 1 ' . $conditiontotal), $params);

            $ordermoney = pdo_fetchcolumn('select sum(price) from ' . tablename('ewei_shop_order') . ' where uniacid=:uniacid and openid=:openid and status=3 limit 1', array(':uniacid' => $_W[‘uniacid’], ‘:openid’ => $member[‘openid’]));

新增记录

            $data = array();
            $data[‘credits’] = $credit;
            $data[‘openid’] = $openid;
            $data[‘uniacid’] = $_W[‘uniacid’];
            $data[‘signinday’] = $signinday;
            $data[‘credits_sum’] = $credits_sum;
            $data[‘signintime’] = $daynow;
            $data[‘totalday’] = $totalday;
            pdo_insert('ewei_shop_sns_sign_in', $data);
            $resid = pdo_insertid(); //返回新插入记录的id

更新记录

        $newcredit = $sns_member[‘credit’] + $credit;

        if ($newcredit <= 0) {
            $newcredit = 0;
        }
        pdo_update('ewei_shop_sns_member', array('credit' => $newcredit), array('id' => $sns_member[‘id’]));

删除记录

直接执行sql语句

            pdo_query('delete from ' . tablename('ewei_shop_goods_spec_item') . (' where uniacid=' . $_W[‘uniacid’] . ' and specid=' . $spec_id . ' and id not in (') . implode(',', $itemids) . ')');

            pdo_delete('ewei_shop_goods', array('id' => $item[‘id’]));

 

 

本文链接:,转发请注明来源!
评论已关闭。