ecmall数据库基本操作,为了认真研究ecmall二次开发,我们必须熟悉ecamll的数据库结构,ecmall数据库结构研究熟悉之后,才能去认真分析ecamll的程序结构。从而实现ecmall二次开发需求。
以下我们总结下ecmall常见数据库操作。
1:查询操作
$item_info = $model_cart->get("spec_id={$spec_id} and goods_id=‘".$spec_info[‘goods_id‘]."‘ AND session_id=‘" . SESS_ID . "‘");
2:删除操作
$droped_rows = $model_cart->drop(‘rec_id=‘ . $rec_id . ‘ AND session_id=\‘‘ . SESS_ID . ‘\‘‘, ‘store_id‘);
3:修改操作
$model_cart->edit($where, array(
‘quantity‘ => $quantity,
));
$model_goodsstatistics->edit($spec_info[‘goods_id‘], ‘carts=carts+1‘);
4:连表查询,left join
$cart_items = $cart_model->find(array(
‘conditions‘ => ‘session_id = \‘‘ . SESS_ID . "‘" .
$where_store_id . $where_user_id,
‘fields‘ =>
‘this.*,store.store_name‘,
‘join‘ =>
‘belongs_to_store‘,
));
5:ecmall的原始数据库写法
$member_model = & m(‘member‘);
$res = $member_model->getRow("select * from
".DB_PREFIX."member where user_id=‘1‘");
6:按简单条件检索数据库find()方法。
$addresses =
$model_address->find(array(
‘conditions‘ => ‘user_id = ‘ .
$this->visitor->get(‘user_id‘),
));