Skip to content

Commit 6e63f59

Browse files
committed
Merge branch 'master' of github.com:thefuzzy0ne/codeigniter-base-model into thefuzzy0ne-master
Conflicts: core/MY_Model.php
2 parents 19a97fd + 0abe142 commit 6e63f59

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
vendor
3-
composer.lock
3+
composer.lock
4+
composer.phar

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ Install the testing framework (PHPUnit) with Composer:
338338

339339
You can then run the tests using the `vendor/bin/phpunit` binary and specify the tests file:
340340

341-
$ vendor/bin/phpunit tests/MY_Model_test.php
341+
$ vendor/bin/phpunit
342342

343343

344344
Contributing to MY_Model

core/MY_Model.php

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,7 @@ public function __construct()
121121
*/
122122
public function get($primary_value)
123123
{
124-
$this->trigger('before_get');
125-
126-
if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE)
127-
{
128-
$this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted);
129-
}
130-
131-
$row = $this->_database->where($this->primary_key, $primary_value)
132-
->get($this->_table)
133-
->{$this->_return_type()}();
134-
$this->_temporary_return_type = $this->return_type;
135-
136-
$row = $this->trigger('after_get', $row);
137-
138-
$this->_with = array();
139-
return $row;
124+
return $this->get_by($this->primary_key, $primary_value);
140125
}
141126

142127
/**
@@ -146,12 +131,13 @@ public function get($primary_value)
146131
public function get_by()
147132
{
148133
$where = func_get_args();
149-
$this->_set_where($where);
150-
134+
151135
if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE)
152136
{
153137
$this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted);
154138
}
139+
140+
$this->_set_where($where);
155141

156142
$this->trigger('before_get');
157143

@@ -186,13 +172,14 @@ public function get_many($values)
186172
public function get_many_by()
187173
{
188174
$where = func_get_args();
189-
$this->_set_where($where);
190175

191176
if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE)
192177
{
193178
$this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted);
194179
}
195180

181+
$this->_set_where($where);
182+
196183
return $this->get_all();
197184
}
198185

phpunit.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@
44
colors="true"
55
convertNoticesToExceptions="true"
66
convertWarningsToExceptions="true">
7+
<testsuites>
8+
<testsuite name="MyModel Test Suite">
9+
<file>./tests/MY_Model_test.php</file>
10+
</testsuite>
11+
</testsuites>
712
</phpunit>

0 commit comments

Comments
 (0)