| 
                         public function getMy($collection = "") { 
if (emptyempty($collection)) { 
$this->error("In order to retreive documents from MongoDB,$this->selects)->limit((int) $this->limit)->skip((int) $this->offset)->sort($this->sorts); 
$returns = array(); 
foreach ($documents as $doc): $returns[] = $doc; 
endforeach; 
$this -> clear(); 
return($returns); 
} 
/*     --------------------------------------------------------------------------------    COUNT   --------------------------------------------------------------------------------      Count the documents based upon the passed parameters      @usage = $this->mongo_db->get('foo'); */ 
public function count($collection = "") { 
if (emptyempty($collection)) { 
$this->error("In order to retreive a count of documents from MongoDB,500); 
} $count = $this->db->{$collection}->find($this->wheres)->limit((int) $this->limit)->skip((int) $this->offset)->count(); 
$this->clear(); 
return($count); 
} 
/     --------------------------------------------------------------------------------    INSERT   --------------------------------------------------------------------------------      Insert a new document into the passed collection      @usage = $this->mongo_db->insert('foo',$data = array()); / 
public function insert($collection = "",$data = array(),$name='ID') { 
if (emptyempty($collection)) { 
$this->error("No Mongo collection selected to insert into",500); 
} if (count($data) == 0 || !is_array($data)) { 
$this->error("Nothing to insert into Mongo collection or insert is not an array",500); 
} try { 
/ 
wxcity_base::load_sys_class('whtysqs','',0); 
$mongoseq_class = new whtysqs('creaseidsqs'); 
$re = $mongoseq_class->query("?name=" . $collection . "&opt=put&data=1"); 
**/ 
$re = put_sqs('list_mongo_creaseidsqs','1'); 
if(is_numeric($re)){ 
$re++; 
$data[$name] = intval($re); 
}else{ 
$data[$name] = intval(time()); 
//die('mongosqs error'); 
} 
$this->db->{$collection}->insert($data,array('fsync' => TRUE)); 
$this->clear(); 
return $data[$name]; 
} catch (MongoCursorException $e) { 
$this->error("Insert of data into MongoDB failed: {$e->getMessage()}",500); 
} 
} 
public function insertWithId($collection = "",$data = array()) { 
if (emptyempty($collection)) { 
$this->error("No Mongo collection selected to insert into",500); 
} try { 
$this->db->{$collection}->insert($data,array('fsync' => TRUE)); 
$this->clear(); 
return 1; 
} catch (MongoCursorException $e) { 
$this->error("Insert of data into MongoDB failed: {$e->getMessage()}",500); 
} 
} 
/*     --------------------------------------------------------------------------------    UPDATE   --------------------------------------------------------------------------------      Update a document into the passed collection      @usage = $this->mongo_db->update('foo',$data = array()); */ 
public function update($collection = "",$data = array()) { 
if (emptyempty($collection)) { 
$this->error("No Mongo collection selected to update",500); 
} if (count($data) == 0 || !is_array($data)) { 
$this->error("Nothing to update in Mongo collection or update is not an array",500); 
} try { 
$this->db->{$collection}->update($this->wheres,array('$set' => $data),array('fsync' => TRUE,'multiple' => FALSE)); 
$this->clear(); 
return(TRUE); 
} catch (MongoCursorException $e) { 
$this->error("Update of data into MongoDB failed: {$e->getMessage()}",500); 
} 
} 
/*     --------------------------------------------------------------------------------    UPDATE_ALL   --------------------------------------------------------------------------------      Insert a new document into the passed collection      @usage = $this->mongo_db->update_all('foo',$data = array()); */ 
public function update_all($collection = "",'multiple' => TRUE)); 
return(TRUE); 
} catch (MongoCursorException $e) { 
$this->error("Update of data into MongoDB failed: {$e->getMessage()}",500); 
} 
} 
                        (编辑:我爱故事小小网_铜陵站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |