refactored MongoModel to hide fetch method, fixed PHPDoc errors
This commit is contained in:
@ -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 = '[';
|
||||
|
Reference in New Issue
Block a user