refactored MongoModel to hide fetch method, fixed PHPDoc errors

This commit is contained in:
Anton Grebnev
2012-10-19 20:15:26 +04:00
parent efb6c2d34c
commit 11a5968105
14 changed files with 436 additions and 187 deletions

View File

@ -22,6 +22,12 @@ class MongoCommandBuilder
const COMMAND = 'Command';
/**
* @param string $type
* @param MongoCollection $collection
* @return MongoDbCommand
*/
static public function factory($type, $collection = null)
{
$class = ucfirst($type) . 'MongoCommand';
@ -33,8 +39,18 @@ class MongoCommandBuilder
abstract class MongoDbCommand
{
/**
* @var MongoCollection
*/
protected $collection;
/**
* Execute Mongo command/query
*
* @return mixed
* @throws GeneralException
*/
public function execute()
{
if ($this->checkParams()) {
@ -44,6 +60,12 @@ abstract class MongoDbCommand
}
}
/**
* @param string $name Parameter name
* @param mixed $value Parameter value
* @return MongoDbCommand
*/
public function bindParam($name, $value)
{
if (property_exists($this, $name)) {
@ -52,12 +74,22 @@ abstract class MongoDbCommand
return $this;
}
/**
* @param MongoCollection $collection Mongo collection
* @return MongoDbCommand
*/
public function setCollection($collection)
{
$this->collection = $collection;
return $this;
}
/**
* Convert query parameters array to string
*
* @param array $array
* @return string
*/
protected function arrayToString($array)
{
$string = '[';