我的地盘

phper

Home Archives
11月 27 2014

检查文档是否存在

<?php
    $mongo = new MongoClient();
    $db = $mongo->dbName;
    $collection = $db->collectionName;

    $cursor = $collection->find(
        $criteria, 
        array('_id' => 1)
    )->limit(1);

    if($coursor->count() == 0){
      exit('not exist');
    }

    exit('exits');
Share
  • mongodb
  • php
Newer
api签名
Older
elasticsearch + logstash + kibana3

Tags

  • api1
  • closures1
  • curl1
  • date1
  • ffmpeg1
  • google1
  • linux3
  • log1
  • memcached1
  • mod_zip1
  • mongodb4
  • mysql1
  • nginx1
  • nignx1
  • photo1
  • php10
  • pyton1
  • sphinx1
  • swoole1
  • web1
  • yii1
  • 骑行1

Tag Cloud

api closures curl date ffmpeg google linux log memcached mod_zip mongodb mysql nginx nignx photo php pyton sphinx swoole web yii 骑行

Archives

  • 八月 20171
  • 八月 20152
  • 三月 20154
  • 二月 20152
  • 一月 20151
  • 十二月 201412
  • 十一月 20144

Recents

  • 修复yum
  • 西湖
  • python文字发音
  • mysql多值查询
  • php的匿名函数
© 2017 jamesBan
Powered by Hexo
Home Archives