From 483ab2326a761ca96097b00695ad5c73bba9c9eb Mon Sep 17 00:00:00 2001 From: Carlos O Carvalho Date: Sat, 6 May 2017 23:15:19 -0300 Subject: [PATCH 1/5] add suporte for illuminate database >= 5.2 --- src/CodeIgniterConnection.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/CodeIgniterConnection.php b/src/CodeIgniterConnection.php index 53fc6c2..4751a88 100644 --- a/src/CodeIgniterConnection.php +++ b/src/CodeIgniterConnection.php @@ -96,15 +96,13 @@ protected function reconnectIfMissingConnection() */ public function select($query, $bindings = array()) { - $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) { + 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)); }); } @@ -147,6 +145,17 @@ public function statement($query, $bindings = array()) return (bool) $self->ci->db->query($query, $bindings); }); } + + /** + * Get fetch mode + * + * @return void + */ + public function getFetchMode() + { + return $this->fetchMode; + } + /** * Run an SQL statement and get the number of rows affected. From b08f085b17b0c940a8e23a76b5074d7969fb908b Mon Sep 17 00:00:00 2001 From: Carlos O Carvalho Date: Sun, 7 May 2017 01:20:46 -0300 Subject: [PATCH 2/5] amment suporte for illuminate database >= 5.2 --- src/CodeIgniterConnection.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/CodeIgniterConnection.php b/src/CodeIgniterConnection.php index 4751a88..ad5f786 100644 --- a/src/CodeIgniterConnection.php +++ b/src/CodeIgniterConnection.php @@ -98,10 +98,8 @@ public function select($query, $bindings = array()) { return $this->run($query, $bindings, function( $query, $bindings) { if ($this->pretending()) return array(); - // pass query to CodeIgniter database layer $bindings = $this->prepareBindings($bindings); - return $this->fetchResult($this->ci->db->query($query, $bindings)); }); } From 189372127a1c498a3d395fef4f367678d27998fa Mon Sep 17 00:00:00 2001 From: Carlos O Carvalho Date: Sun, 7 May 2017 01:36:28 -0300 Subject: [PATCH 3/5] amment suporte for illuminate database >= 5.2 --- src/CodeIgniterConnection.php | 47 +++++++++++++++++------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/CodeIgniterConnection.php b/src/CodeIgniterConnection.php index ad5f786..e76ef0b 100644 --- a/src/CodeIgniterConnection.php +++ b/src/CodeIgniterConnection.php @@ -94,16 +94,26 @@ protected function reconnectIfMissingConnection() * @param array $bindings * @return array */ - public function select($query, $bindings = array()) + public function select($query, $bindings = array(), $useReadPdo = false) { - return $this->run($query, $bindings, function( $query, $bindings) { + $self = $this; + + 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 = $this->prepareBindings($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 * @@ -134,26 +144,15 @@ 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); }); } - - /** - * Get fetch mode - * - * @return void - */ - public function getFetchMode() - { - return $this->fetchMode; - } - /** * Run an SQL statement and get the number of rows affected. @@ -164,17 +163,17 @@ public function getFetchMode() */ 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(); }); } From 42e4981b717d611e5723b05fb93ab9775086979c Mon Sep 17 00:00:00 2001 From: Carlos O Carvalho Date: Tue, 9 May 2017 01:56:31 -0300 Subject: [PATCH 4/5] change composer version namespace --- composer.json | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 116c37f..c2fb666 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,14 +13,17 @@ "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" @@ -29,4 +32,4 @@ "mockery/mockery": "~0.9", "phpunit/phpunit": "~4.1" } -} +} \ No newline at end of file From 0e8ab27e30df3f48a7a7b38fa49e82a3a243bcd4 Mon Sep 17 00:00:00 2001 From: Carlos O Carvalho Date: Tue, 9 May 2017 02:03:38 -0300 Subject: [PATCH 5/5] change composer requires --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c2fb666..f058ec1 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "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",