Commit 06293089 authored by zhz's avatar zhz

添加商品快照

parent f263cd0b
......@@ -483,7 +483,11 @@ class GoodsModel extends \DAO\AbstractModel {
return true;
}
public function update($data, $where){
$this->setDb(\Our\DbNameConst::masterDBConnectName);
$result = $this->db->update($this->_tableName)->rows($data)->where($where)->execute();
return $result;
}
/**
* 获取格式化的规格值
......
<?php
namespace DAO\Goods;
class GoodsSnapshotModel extends \DAO\AbstractModel
{
/**
* 表名
*
* @var string
*/
protected $_tableName = 'han_goods_snapshot';
/**
* 主键
*
* @var string
*/
protected $_primaryKey = 'id';
public function init()
{
}
public function insert($data)
{
$this->setDb(\Our\DbNameConst::masterDBConnectName);
return $this->db->insert($this->_tableName)->rows($data)->execute();
}
public function save($data, $where){
$this->setDb(\Our\DbNameConst::masterDBConnectName);
$result = $this->db->update($this->_tableName)->rows($data)->where($where)->execute();
return $result;
}
/**
* 类实例
*
* @var \DAO\UserModel
*/
private static $_instance = null;
/**
* 获取类实例
*
* @return \DAO\UserModel
*/
public static function getInstance()
{
if (!(self::$_instance instanceof self)) {
self::$_instance = new self();
}
return self::$_instance;
}
}
<?php
/**
* 添加商品快照
* 执行一次
*/
define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级
require APPLICATION_PATH . '/scripts/crontab/common.php';
$goodsList = \DAO\GoodsModel::getInstance()->getList(array('snapshot_id'=>0),'*');
foreach ($goodsList as $goods) {
$snaId = \DAO\Goods\GoodsSnapshotModel::getInstance()->insert(array('content'=>serialize($goods),'type'=>1));
\DAO\GoodsModel::getInstance()->update(array('snapshot_id'=>$snaId),array('goods_id'=>$goods['goods_id']));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment