提交 d76c6cee 编写于 作者: R root

php mongodb扩展升级2.0,支持php7,已兼容,使用php ext-mongodb扩展,ext-mongo扩展可以废除

上级 ac649a03
......@@ -56,7 +56,7 @@ class Index {
foreach($coll as $one){
$p_id = $one['product_id'];
$product_ids[] = new \MongoId($p_id) ;
$product_ids[] = new \MongoDB\BSON\ObjectId($p_id) ;
$favorites[$p_id] = [
'updated_at' => $one['updated_at'],
'favorite_id' => (string)$one['_id'],
......
......@@ -284,7 +284,7 @@ class Product extends Service
if(!empty($ids) && is_array($ids)){
$ids_ob_arr = [];
foreach($ids as $id){
$ids_ob_arr[] = new \MongoId($id);
$ids_ob_arr[] = new \MongoDB\BSON\ObjectId($id);
}
$filter = [
'where' => [
......
......@@ -85,7 +85,7 @@ class CategoryMongodb implements CategoryInterface
$model = new Category;
$model->created_at = time();
$model->created_user_id = \fec\helpers\CUser::getCurrentUserId();
$primaryVal = new \MongoId;
$primaryVal = new \MongoDB\BSON\ObjectId();
$model->{$this->getPrimaryKey()} = $primaryVal;
$parent_id = $one['parent_id'];
}
......@@ -224,7 +224,7 @@ class CategoryMongodb implements CategoryInterface
if($parent_id === '0'){
return [];
}
$category = Category::find()->asArray()->where(['_id' => new \MongoId($parent_id)])->one();
$category = Category::find()->asArray()->where(['_id' => new \MongoDB\BSON\ObjectId($parent_id)])->one();
if(isset($category['_id']) && !empty($category['_id']) ){
$currentUrlKey = $category['url_key'];
$currentName = $category['name'];
......
......@@ -70,7 +70,7 @@ class ArticleMongodb implements ArticleInterface
$model = new Article;
$model->created_at = time();
$model->created_user_id = \fec\helpers\CUser::getCurrentUserId();
$primaryVal = new \MongoId;
$primaryVal = new \MongoDB\BSON\ObjectId();
$model->{$this->getPrimaryKey()} = $primaryVal;
}
$model->updated_at = time();
......
......@@ -81,7 +81,7 @@ class StaticBlockMongodb implements StaticBlockInterface
$model = new StaticBlock;
$model->created_at = time();
$model->created_user_id = \fec\helpers\CUser::getCurrentUserId();
$primaryVal = new \MongoId;
$primaryVal = new \MongoDB\BSON\ObjectId();
$model->{$this->getPrimaryKey()} = $primaryVal;
}
......@@ -99,7 +99,7 @@ class StaticBlockMongodb implements StaticBlockInterface
$query = StaticBlock::find()->asArray();
$query->where(['identify' => $identify]);
if($primaryVal){
$query->andWhere([$id => ['$ne'=> new \MongoId($primaryVal)]]);
$query->andWhere([$id => ['$ne'=> new \MongoDB\BSON\ObjectId($primaryVal)]]);
}
$one = $query->one();
......
......@@ -150,7 +150,7 @@ class Favorite extends Service
$user_id = $identity['id'];
$one = FavoriteModel::findOne([
'_id' => new \MongoId($favorite_id),
'_id' => new \MongoDB\BSON\ObjectId($favorite_id),
'user_id' => $user_id,
]);
if($one['_id']){
......
......@@ -119,7 +119,7 @@ class ProductMongodb implements ProductInterface
$query = Product::find()->asArray();
$mongoIds = [];
foreach($product_id_arr as $id){
$mongoIds[] = new \MongoId($id);
$mongoIds[] = new \MongoDB\BSON\ObjectId($id);
}
//var_dump($mongoIds);
$query->where(['in',$this->getPrimaryKey(),$mongoIds]);
......@@ -158,7 +158,7 @@ class ProductMongodb implements ProductInterface
}
#验证sku 是否重复
$product_one = Product::find()->asArray()->where([
'<>',$this->getPrimaryKey(),(new \MongoId($primaryVal))
'<>',$this->getPrimaryKey(),(new \MongoDB\BSON\ObjectId($primaryVal))
])->andWhere([
'sku' => $one['sku'],
])->one();
......@@ -170,7 +170,7 @@ class ProductMongodb implements ProductInterface
$model = new Product;
$model->created_at = time();
$model->created_user_id = \fec\helpers\CUser::getCurrentUserId();
$primaryVal = new \MongoId;
$primaryVal = new \MongoDB\BSON\ObjectId();
$model->{$this->getPrimaryKey()} = $primaryVal;
#验证sku 是否重复
$product_one = Product::find()->asArray()->where([
......
......@@ -239,7 +239,7 @@ class Review extends Service
}else{
$model = new ReviewModel;
$model->created_admin_user_id = \fec\helpers\CUser::getCurrentUserId();
$primaryVal = new \MongoId;
$primaryVal = new \MongoDB\BSON\ObjectId();
$model->{$this->getPrimaryKey()} = $primaryVal;
}
//$review_data['status'] = ReviewModel::ACTIVE_STATUS;
......
......@@ -149,7 +149,7 @@ class XunSearch extends Service implements SearchInterface
$limit = $numPerPage;
$productIds = [];
foreach($data as $d){
$productIds[] = new \MongoId($d['_id']);
$productIds[] = new \MongoDB\BSON\ObjectId($d['_id']);
}
$productIds = array_slice($productIds, $offset, $limit);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册