Commit 5493b6b1 authored by Jens Segers's avatar Jens Segers

Now using v4.0.x packages

parent 3827a515
...@@ -81,7 +81,7 @@ Everything else works just like the original Eloquent model. Read more about the ...@@ -81,7 +81,7 @@ Everything else works just like the original Eloquent model. Read more about the
Query Builder Query Builder
------------- -------------
Once selected a mongodb connection, you can execute queries just like the original query builder. The main difference is that we are using `collection` instead of `table` (but table will work as well), and some additional operations like `push` and `pull`. Once you have selected a mongodb connection, you can execute queries just like the original query builder. The main difference is that we are using `collection` instead of `table` (but table will work as well), and some additional operations like `push` and `pull`.
// With custom connection // With custom connection
$user = DB::connection('mongodb')->collection('users')->get(); $user = DB::connection('mongodb')->collection('users')->get();
......
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
"license" : "MIT", "license" : "MIT",
"require": { "require": {
"php": ">=5.3.0", "php": ">=5.3.0",
"illuminate/support": "~4.0", "illuminate/support": "4.0.x",
"illuminate/database": "~4.0", "illuminate/database": "4.0.x",
"illuminate/events": "~4.0" "illuminate/events": "4.0.x"
}, },
"require-dev": { "require-dev": {
"illuminate/cache": "~4.0" "illuminate/cache": "4.0.x"
}, },
"autoload": { "autoload": {
"psr-0": { "psr-0": {
......
...@@ -11,7 +11,7 @@ class Builder extends \Illuminate\Database\Query\Builder { ...@@ -11,7 +11,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
* *
* @var MongoCollection * @var MongoCollection
*/ */
public $collection; protected $collection;
/** /**
* All of the available operators. * All of the available operators.
...@@ -495,7 +495,7 @@ class Builder extends \Illuminate\Database\Query\Builder { ...@@ -495,7 +495,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
* *
* @return array * @return array
*/ */
private function compileWheres() protected function compileWheres()
{ {
if (!$this->wheres) return array(); if (!$this->wheres) return array();
...@@ -507,6 +507,7 @@ class Builder extends \Illuminate\Database\Query\Builder { ...@@ -507,6 +507,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
// Convert id's // Convert id's
if (isset($where['column']) && $where['column'] == '_id') if (isset($where['column']) && $where['column'] == '_id')
{ {
// Multiple values
if (isset($where['values'])) if (isset($where['values']))
{ {
foreach ($where['values'] as &$value) foreach ($where['values'] as &$value)
...@@ -514,6 +515,7 @@ class Builder extends \Illuminate\Database\Query\Builder { ...@@ -514,6 +515,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
$value = ($value instanceof MongoID) ? $value : new MongoID($value); $value = ($value instanceof MongoID) ? $value : new MongoID($value);
} }
} }
// Single value
else else
{ {
$where['value'] = ($where['value'] instanceof MongoID) ? $where['value'] : new MongoID($where['value']); $where['value'] = ($where['value'] instanceof MongoID) ? $where['value'] : new MongoID($where['value']);
...@@ -544,7 +546,7 @@ class Builder extends \Illuminate\Database\Query\Builder { ...@@ -544,7 +546,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
return $wheres; return $wheres;
} }
private function compileWhereBasic($where) protected function compileWhereBasic($where)
{ {
extract($where); extract($where);
...@@ -573,28 +575,28 @@ class Builder extends \Illuminate\Database\Query\Builder { ...@@ -573,28 +575,28 @@ class Builder extends \Illuminate\Database\Query\Builder {
return $query; return $query;
} }
private function compileWhereNested($where) protected function compileWhereNested($where)
{ {
extract($where); extract($where);
return $query->compileWheres(); return $query->compileWheres();
} }
private function compileWhereIn($where) protected function compileWhereIn($where)
{ {
extract($where); extract($where);
return array($column => array('$in' => $values)); return array($column => array('$in' => $values));
} }
private function compileWhereNotIn($where) protected function compileWhereNotIn($where)
{ {
extract($where); extract($where);
return array($column => array('$nin' => $values)); return array($column => array('$nin' => $values));
} }
private function compileWhereNull($where) protected function compileWhereNull($where)
{ {
$where['operator'] = '='; $where['operator'] = '=';
$where['value'] = null; $where['value'] = null;
...@@ -602,7 +604,7 @@ class Builder extends \Illuminate\Database\Query\Builder { ...@@ -602,7 +604,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
return $this->compileWhereBasic($where); return $this->compileWhereBasic($where);
} }
private function compileWhereNotNull($where) protected function compileWhereNotNull($where)
{ {
$where['operator'] = '!='; $where['operator'] = '!=';
$where['value'] = null; $where['value'] = null;
...@@ -610,7 +612,7 @@ class Builder extends \Illuminate\Database\Query\Builder { ...@@ -610,7 +612,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
return $this->compileWhereBasic($where); return $this->compileWhereBasic($where);
} }
private function compileWhereBetween($where) protected function compileWhereBetween($where)
{ {
extract($where); extract($where);
...@@ -621,7 +623,7 @@ class Builder extends \Illuminate\Database\Query\Builder { ...@@ -621,7 +623,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
); );
} }
private function compileWhereRaw($where) protected function compileWhereRaw($where)
{ {
return $where['sql']; return $where['sql'];
} }
......
...@@ -8,6 +8,8 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo { ...@@ -8,6 +8,8 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo {
* @return void * @return void
*/ */
public function addConstraints() public function addConstraints()
{
if (static::$constraints)
{ {
// For belongs to relationships, which are essentially the inverse of has one // For belongs to relationships, which are essentially the inverse of has one
// or has many relationships, we need to actually query on the primary key // or has many relationships, we need to actually query on the primary key
...@@ -16,6 +18,7 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo { ...@@ -16,6 +18,7 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo {
$this->query->where($key, '=', $this->parent->{$this->foreignKey}); $this->query->where($key, '=', $this->parent->{$this->foreignKey});
} }
}
/** /**
* Set the constraints for an eager load of the relation. * Set the constraints for an eager load of the relation.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment