diff --git a/composer.json b/composer.json index 116c37f..f058ec1 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "expressodev/laravel-codeigniter-db", + "name": "carlosocarvalho/eloquent-codeigniter", "type": "library", "description": "Integration layer allowing use of the Laravel database library in CodeIgniter applications", "keywords": [ @@ -13,20 +13,24 @@ "orm" ], "license": "MIT", - "authors": [ - { + "authors": [{ "name": "Adrian Macneil", "email": "adrian@adrianmacneil.com" + }, + { + "name": "Carlos Carvalho", + "email": "contato@carlosocarvalho.com.br" } ], "autoload": { - "psr-4": { "Illuminate\\CodeIgniter\\" : "src/" } + "psr-4": { "Illuminate\\CodeIgniter\\": "src/" } }, "require": { - "illuminate/database": "~4.1|~5.0" + "illuminate/database": "5.2", + "php": ">=5.4" }, "require-dev": { "mockery/mockery": "~0.9", "phpunit/phpunit": "~4.1" } -} +} \ No newline at end of file diff --git a/src/CodeIgniterConnection.php b/src/CodeIgniterConnection.php index 53fc6c2..e76ef0b 100644 --- a/src/CodeIgniterConnection.php +++ b/src/CodeIgniterConnection.php @@ -94,20 +94,26 @@ protected function reconnectIfMissingConnection() * @param array $bindings * @return array */ - public function select($query, $bindings = array()) + public function select($query, $bindings = array(), $useReadPdo = false) { $self = $this; - return $this->run($query, $bindings, function($me, $query, $bindings) use ($self) { - if ($me->pretending()) return array(); + return $this->run($query, $bindings, function( $query, $bindings) use ($self, $useReadPdo) { + //dump( $me->pretending()); + if ($this->pretending()) return array(); - // pass query to CodeIgniter database layer - $bindings = $me->prepareBindings($bindings); + $bindings = $this->prepareBindings($bindings); - return $self->fetchResult($self->ci->db->query($query, $bindings)); + return $this->fetchResult($this->ci->db->query($query, $bindings)); }); } + + public function getFetchMode() + { + return $this->fetchMode; + } + /** * Fetch a CodeIgniter result set as an array or object, emulating current PDO fetch mode * @@ -138,13 +144,13 @@ public function statement($query, $bindings = array()) { $self = $this; - return $this->run($query, $bindings, function($me, $query, $bindings) use ($self) { - if ($me->pretending()) return true; + return $this->run($query, $bindings, function( $query, $bindings) { + if ($this->pretending()) return true; // pass query to CodeIgniter database layer - $bindings = $me->prepareBindings($bindings); + $bindings = $this->prepareBindings($bindings); - return (bool) $self->ci->db->query($query, $bindings); + return (bool) $this->ci->db->query($query, $bindings); }); } @@ -157,17 +163,17 @@ public function statement($query, $bindings = array()) */ public function affectingStatement($query, $bindings = array()) { - $self = $this; + - return $this->run($query, $bindings, function($me, $query, $bindings) use ($self) { - if ($me->pretending()) return 0; + return $this->run($query, $bindings, function( $query, $bindings) { + if ($this->pretending()) return 0; // pass query to CodeIgniter database layer - $bindings = $me->prepareBindings($bindings); - $self->ci->db->query($query, $bindings); + $bindings = $this->prepareBindings($bindings); + $this->ci->db->query($query, $bindings); // return number of rows affected - return $self->ci->db->affected_rows(); + return $this->ci->db->affected_rows(); }); }