Skip to content

Commit 6d2fdf3

Browse files
authored
Merge pull request #36 from marcelovsantos/master
Correction test for 5.3 and 5.4
2 parents 955214b + 418990d commit 6d2fdf3

File tree

3 files changed

+43
-10
lines changed

3 files changed

+43
-10
lines changed

Database/SybaseConnection.php

+20-8
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,9 @@ private function queryStringForPrimaries($from)
457457
*/
458458
public function select($query, $bindings = array(), $useReadPdo = true)
459459
{
460-
return $this->run($query, $bindings, function($me, $query, $bindings) use ($useReadPdo)
460+
return $this->run($query, $bindings, function($query, $bindings) use ($useReadPdo)
461461
{
462-
if ($me->pretending()) {
462+
if ($this->pretending()) {
463463
return array();
464464
}
465465

@@ -470,18 +470,20 @@ public function select($query, $bindings = array(), $useReadPdo = true)
470470
}
471471

472472
if ($offset > 0) {
473-
return $this->compileOffset($offset, $query, $bindings, $me);
473+
return $this->compileOffset($offset, $query, $bindings, $this);
474474
} else {
475475
$result = [];
476476
$statement = $this->getPdo()->query($this->compileNewQuery($query, $bindings));
477477
do {
478-
$result+= $statement->fetchAll($me->getFetchMode());
478+
$result+= $statement->fetchAll($this->getFetchMode());
479479
} while ($statement->nextRowset());
480480
return $result;
481481
}
482482
});
483483
}
484484

485+
486+
485487

486488
/**
487489
* @param string $query
@@ -490,9 +492,9 @@ public function select($query, $bindings = array(), $useReadPdo = true)
490492
*/
491493
public function statement($query, $bindings = array())
492494
{
493-
return $this->run($query, $bindings, function($me, $query, $bindings)
495+
return $this->run($query, $bindings, function($query, $bindings)
494496
{
495-
if ($me->pretending()) {
497+
if ($this->pretending()) {
496498
return true;
497499
}
498500
return $this->getPdo()->query($this->compileNewQuery($query, $bindings));
@@ -501,12 +503,22 @@ public function statement($query, $bindings = array())
501503

502504
public function affectingStatement($query, $bindings = array())
503505
{
504-
return $this->run($query, $bindings, function($me, $query, $bindings)
506+
return $this->run($query, $bindings, function($query, $bindings)
505507
{
506-
if ($me->pretending()) {
508+
if ($this->pretending()) {
507509
return 0;
508510
}
509511
return $this->getPdo()->query($this->compileNewQuery($query, $bindings))->rowCount();
510512
});
511513
}
514+
515+
/**
516+
* Get the default fetch mode for the connection.
517+
*
518+
* @return int
519+
*/
520+
public function getFetchMode()
521+
{
522+
return $this->fetchMode;
523+
}
512524
}

Database/SybaseConnector.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Uepg\LaravelSybase\Database;
4+
5+
use Illuminate\Database\Connectors\SqlServerConnector;
6+
7+
class SybaseConnector extends SqlServerConnector
8+
{
9+
10+
}

Database/SybaseServiceProvider.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php namespace Uepg\LaravelSybase\Database;
22

33
use Uepg\LaravelSybase\Database\SybaseConnection;
4+
use Uepg\LaravelSybase\Database\SybaseConnector;
45
use Illuminate\Support\ServiceProvider;
6+
use Illuminate\Database\Connection;
57

68
class SybaseServiceProvider extends ServiceProvider
79
{
@@ -12,9 +14,18 @@ class SybaseServiceProvider extends ServiceProvider
1214
*/
1315
public function register()
1416
{
15-
$this->app->bind('db.connection.sqlsrv', function ($app, $parameters) {
16-
list($connection, $database, $prefix, $config) = $parameters;
17+
18+
Connection::resolverFor('sqlsrv', function ($connection, $database, $prefix, $config) {
1719
return new SybaseConnection($connection, $database, $prefix, $config);
1820
});
21+
22+
$this->app->bind('db.connector.sqlsrv', function ($app) {
23+
return new SybaseConnector();
24+
});
25+
26+
// $this->app->bind('db.connection.sqlsrv', function ($app, $parameters) {
27+
// list($connection, $database, $prefix, $config) = $parameters;
28+
// return new SybaseConnection($connection, $database, $prefix, $config);
29+
// });
1930
}
2031
}

0 commit comments

Comments
 (0)