Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -13,20 +13,24 @@
"orm"
],
"license": "MIT",
"authors": [
{
"authors": [{
"name": "Adrian Macneil",
"email": "[email protected]"
},
{
"name": "Carlos Carvalho",
"email": "[email protected]"
}
],
"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"
}
}
}
38 changes: 22 additions & 16 deletions src/CodeIgniterConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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);
});
}

Expand All @@ -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();
});
}

Expand Down