Skip to content

Commit 5493b6b

Browse files
committed
Now using v4.0.x packages
1 parent 3827a51 commit 5493b6b

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Everything else works just like the original Eloquent model. Read more about the
8181
Query Builder
8282
-------------
8383

84-
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`.
84+
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`.
8585

8686
// With custom connection
8787
$user = DB::connection('mongodb')->collection('users')->get();

composer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
"license" : "MIT",
1212
"require": {
1313
"php": ">=5.3.0",
14-
"illuminate/support": "~4.0",
15-
"illuminate/database": "~4.0",
16-
"illuminate/events": "~4.0"
14+
"illuminate/support": "4.0.x",
15+
"illuminate/database": "4.0.x",
16+
"illuminate/events": "4.0.x"
1717
},
1818
"require-dev": {
19-
"illuminate/cache": "~4.0"
19+
"illuminate/cache": "4.0.x"
2020
},
2121
"autoload": {
2222
"psr-0": {

src/Jenssegers/Mongodb/Builder.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Builder extends \Illuminate\Database\Query\Builder {
1111
*
1212
* @var MongoCollection
1313
*/
14-
public $collection;
14+
protected $collection;
1515

1616
/**
1717
* All of the available operators.
@@ -495,7 +495,7 @@ protected function performUpdate($query)
495495
*
496496
* @return array
497497
*/
498-
private function compileWheres()
498+
protected function compileWheres()
499499
{
500500
if (!$this->wheres) return array();
501501

@@ -507,13 +507,15 @@ private function compileWheres()
507507
// Convert id's
508508
if (isset($where['column']) && $where['column'] == '_id')
509509
{
510+
// Multiple values
510511
if (isset($where['values']))
511512
{
512513
foreach ($where['values'] as &$value)
513514
{
514515
$value = ($value instanceof MongoID) ? $value : new MongoID($value);
515516
}
516517
}
518+
// Single value
517519
else
518520
{
519521
$where['value'] = ($where['value'] instanceof MongoID) ? $where['value'] : new MongoID($where['value']);
@@ -544,7 +546,7 @@ private function compileWheres()
544546
return $wheres;
545547
}
546548

547-
private function compileWhereBasic($where)
549+
protected function compileWhereBasic($where)
548550
{
549551
extract($where);
550552

@@ -573,44 +575,44 @@ private function compileWhereBasic($where)
573575
return $query;
574576
}
575577

576-
private function compileWhereNested($where)
578+
protected function compileWhereNested($where)
577579
{
578580
extract($where);
579581

580582
return $query->compileWheres();
581583
}
582584

583-
private function compileWhereIn($where)
585+
protected function compileWhereIn($where)
584586
{
585587
extract($where);
586588

587589
return array($column => array('$in' => $values));
588590
}
589591

590-
private function compileWhereNotIn($where)
592+
protected function compileWhereNotIn($where)
591593
{
592594
extract($where);
593595

594596
return array($column => array('$nin' => $values));
595597
}
596598

597-
private function compileWhereNull($where)
599+
protected function compileWhereNull($where)
598600
{
599601
$where['operator'] = '=';
600602
$where['value'] = null;
601603

602604
return $this->compileWhereBasic($where);
603605
}
604606

605-
private function compileWhereNotNull($where)
607+
protected function compileWhereNotNull($where)
606608
{
607609
$where['operator'] = '!=';
608610
$where['value'] = null;
609611

610612
return $this->compileWhereBasic($where);
611613
}
612614

613-
private function compileWhereBetween($where)
615+
protected function compileWhereBetween($where)
614616
{
615617
extract($where);
616618

@@ -621,7 +623,7 @@ private function compileWhereBetween($where)
621623
);
622624
}
623625

624-
private function compileWhereRaw($where)
626+
protected function compileWhereRaw($where)
625627
{
626628
return $where['sql'];
627629
}

src/Jenssegers/Mongodb/Relations/BelongsTo.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ class BelongsTo extends \Illuminate\Database\Eloquent\Relations\BelongsTo {
99
*/
1010
public function addConstraints()
1111
{
12-
// For belongs to relationships, which are essentially the inverse of has one
13-
// or has many relationships, we need to actually query on the primary key
14-
// of the related models matching on the foreign key that's on a parent.
15-
$key = $this->related->getKeyName();
12+
if (static::$constraints)
13+
{
14+
// For belongs to relationships, which are essentially the inverse of has one
15+
// or has many relationships, we need to actually query on the primary key
16+
// of the related models matching on the foreign key that's on a parent.
17+
$key = $this->related->getKeyName();
1618

17-
$this->query->where($key, '=', $this->parent->{$this->foreignKey});
19+
$this->query->where($key, '=', $this->parent->{$this->foreignKey});
20+
}
1821
}
1922

2023
/**

0 commit comments

Comments
 (0)