CACHE_KEY
CACHE_KEY = array(__CLASS__, "ss_order") : string
缓存的键列表
<?php
/** ---- eapie ----
* 优狐积木框架,让开发就像组装积木一样简单!
* 解放千千万万程序员!这只是1.0版本,后续版本势如破竹!
*
* QQ群:523668865
* 开源地址 https://gitee.com/lxh888/openshop
* 官网 http://eonfox.com/
* 后端框架文档 http://cao.php.eonfox.com
*
* 作者:绵阳市优狐网络科技有限公司
* 电话/微信:18981181942
* QQ:294520544
*/
namespace eapie\source\table\softstore;
use eapie\main;
class ss_order_product extends main {
/**
* 缓存的键列表
*
* @var string
*/
const CACHE_KEY = array(__CLASS__, "ss_order");
/**
* 数据检测
*
* @var array
*/
public $check = array(
"ss_order_product_number" => array(
//参数检测
'args'=>array(
'echo'=>array("购买数量的数据类型不合法"),
'match'=>array('/^[0-9]{0,}$/i', "购买数量必须是整数"),
),
),
);
/**
* 获取一个id号
*
* @param void
* @return string
*/
public function get_unique_id(){
return cmd(array(22), 'random autoincrement');
}
/**
* 获取一个数据
*
* @param string $ss_order_product_id
* @return array
*/
public function find($ss_order_product_id = ''){
if( empty($ss_order_product_id) ){
return false;
}
return object(parent::CACHE)->data(__CLASS__, __METHOD__, array($ss_order_product_id), function($ss_order_product_id){
return db(parent::DB_APPLICATION_ID)
->table('ss_order_product')
->where(array('ss_order_product_id=[+]', (string)$ss_order_product_id))
->find();
});
}
/**
* 插入新数据
*
* @param array $data 数据
* @param array $call_data 数据
* @return bool
*/
public function insert($data = array(), $call_data = array()){
if( empty($data) && empty($call_data) ){
return false;
}
$bool = (bool)db(parent::DB_APPLICATION_ID)
->table('ss_order_product')
->call('data', $call_data)
->insert($data);
if( !empty($bool) ){
//清理当前项目缓存
object(parent::CACHE)->clear(self::CACHE_KEY);
}
return $bool;
}
/**
* 更新数据
*
* @param array $where
* @param array $data
* @param array $call_data
* @return bool
*/
public function update($where = array(), $data = array(), $call_data = array()){
if( empty($where) || (empty($data) && empty($call_data)) ){
return false;
}
$bool = (bool)db(parent::DB_APPLICATION_ID)
->table('ss_order_product')
->call('where', $where)
->call('data', $call_data)
->update($data);
if( !empty($bool) ){
//清理当前项目缓存
object(parent::CACHE)->clear(self::CACHE_KEY);
}
return $bool;
}
/**
* 删除数据
*
* @param array $where
* @return array
*/
public function delete($where = array()){
if( empty($where) ){
return false;
}
$bool = (bool)db(parent::DB_APPLICATION_ID)
->table('ss_order_product')
->call('where', $where)
->delete();
if( !empty($bool) ){
//清理当前项目缓存
object(parent::CACHE)->clear(self::CACHE_KEY);
}
return $bool;
}
/**
* 根据唯一标识,删除数据
*
* @param array $ss_order_product_id
* @return array
*/
public function remove($ss_order_product_id = ''){
if( empty($ss_order_product_id) ){
return false;
}
$bool = (bool)db(parent::DB_APPLICATION_ID)
->table('ss_order_product')
->where(array('ss_order_product_id=[+]', (string)$ss_order_product_id))
->delete();
if( !empty($bool) ){
//清理当前项目缓存
object(parent::CACHE)->clear(self::CACHE_KEY);
}
return $bool;
}
/**
* 获取多条数据
* $config = array(
* 'where' => array(), //条件
* 'orderby' => array(), //排序
* 'limit' => array(0, page_size), //取出条数,默认不限制
* 'select' => array(),//查询的字段,可以是数组和字符串
* );
*
* @param array $config
* @return array
*/
public function select($config = array()){
return object(parent::CACHE)->data(__CLASS__, __METHOD__, array($config), function($config){
$where = isset($config['where']) && is_array($config['where'])? $config['where'] : array();
$orderby = isset($config['orderby']) && is_array($config['orderby'])? $config['orderby'] : array();
$limit = isset($config['limit']) && is_array($config['limit'])? $config['limit'] : array();
$select = isset($config['select']) && is_array($config['select'])? $config['select'] : array();
return db(parent::DB_APPLICATION_ID)
->table('ss_order_product')
->call('where', $where)
->call('orderby', $orderby)
->call('limit', $limit)
->select($select);
});
}
}
?>