modified model classes with tests

This commit is contained in:
Anton Grebnev
2011-11-17 15:12:47 +04:00
parent e740ae7000
commit 7e8fe0f94d
10 changed files with 212 additions and 85 deletions

View File

@ -13,26 +13,11 @@
abstract class MongoModel extends Model
{
public function find($condition)
public function find($condition = array())
{
return $this->db->find($this->table(), $condition);
}
protected function order(MongoStatement $cursor, $sort = array())
{
return $cursor->sort($sort);
}
protected function skip(MongoStatement $cursor, $skip = 0)
{
return $cursor->skip($skip);
}
protected function limit(MongoStatement $cursor, $limit = 0)
{
return $cursor->limit($limit);
}
public function get($id)
{
return $this->db->get($this->table(), array('_id' => $id))->fetch();
@ -40,7 +25,7 @@ abstract class MongoModel extends Model
public function delete($id)
{
return $this->db->delete($this->table(), array('id' => $id));
return $this->db->delete($this->table(), array('_id' => $id));
}
protected function fetchField($data, $params = array(), $field, $cache_key = null)