Skip to content

Commit

Permalink
Merge pull request #25 from eflorea/php-7_2-count-function-bugfix
Browse files Browse the repository at this point in the history
PHP 7.2 bug fix for `count()` function
  • Loading branch information
Eduard Florea committed May 10, 2018
2 parents 34ba681 + 5d0668b commit 580e3ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 58 deletions.
39 changes: 10 additions & 29 deletions src/RPC/Db/Table/Adapter/MSSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function get()

if( ! isset( $args[0] ) )
{
return null;
return [];
}

$condition_values = array();
Expand Down Expand Up @@ -161,12 +161,7 @@ public function get()
$res = $this->getDb()->query( $sql );
}

if( count( $res ) )
{
return $res[0];
}

return null;
return $res ? $res[0] : [];
}


Expand All @@ -178,12 +173,8 @@ public function getAll()
{
$sql = 'select top 1000 * from "' . $this->getName() . '"';
$res = $this->getDb()->query( $sql );
if( count( $res ) )
{
return $res;
}

return null;
return $res ?: [];
}

$condition_values = array();
Expand Down Expand Up @@ -237,12 +228,7 @@ public function getAll()
$res = $this->getDb()->query( $sql );
}

if( count( $res ) )
{
return $res;
}

return null;
return $res ?: [];
}


Expand Down Expand Up @@ -306,12 +292,7 @@ public function getBySql()
$res = $this->getDb()->query( $sql );
}

if( count( $res ) )
{
return $res;
}

return null;
return $res ?: [];
}


Expand Down Expand Up @@ -377,7 +358,7 @@ public function find()
$res = $this->getDb()->query( $sql );
}

if( count( $res ) )
if( $res )
{
$row = $res[0];

Expand Down Expand Up @@ -466,7 +447,7 @@ public function findAll()



if( count( $res ) )
if( $res )
{
$fields = $this->getFields();

Expand All @@ -493,7 +474,7 @@ public function findAll()
return $output;
}

return null;
return [];
}

public function findBySql()
Expand Down Expand Up @@ -558,7 +539,7 @@ public function findBySql()
$res = $this->getDb()->query( $sql );
}

if( count( $res ) )
if( $res )
{
$output = array();

Expand All @@ -583,7 +564,7 @@ public function findBySql()
return $output;
}

return null;
return [];
}


Expand Down
39 changes: 10 additions & 29 deletions src/RPC/Db/Table/Adapter/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function get()

if( ! isset( $args[0] ) )
{
return null;
return [];
}

$condition_values = array();
Expand Down Expand Up @@ -162,12 +162,7 @@ public function get()
$res = $this->getDb()->query( $sql );
}

if( count( $res ) )
{
return $res[0];
}

return null;
return $res ? $res[0] : [];
}


Expand All @@ -179,12 +174,8 @@ public function getAll()
{
$sql = "select * from `" . $this->getName() . "` limit 1000";
$res = $this->getDb()->query( $sql );
if( count( $res ) )
{
return $res;
}

return null;
return $res ?: [];
}

$condition_values = array();
Expand Down Expand Up @@ -238,12 +229,7 @@ public function getAll()
$res = $this->getDb()->query( $sql );
}

if( count( $res ) )
{
return $res;
}

return null;
return $res ?: [];
}


Expand Down Expand Up @@ -307,12 +293,7 @@ public function getBySql()
$res = $this->getDb()->query( $sql );
}

if( count( $res ) )
{
return $res;
}

return null;
return $res ?: [];
}


Expand Down Expand Up @@ -378,7 +359,7 @@ public function find()
$res = $this->getDb()->query( $sql );
}

if( count( $res ) )
if( $res )
{
$row = $res[0];

Expand Down Expand Up @@ -467,7 +448,7 @@ public function findAll()



if( count( $res ) )
if( $res )
{
$fields = $this->getFields();

Expand All @@ -494,7 +475,7 @@ public function findAll()
return $output;
}

return null;
return [];
}

public function findBySql()
Expand Down Expand Up @@ -559,7 +540,7 @@ public function findBySql()
$res = $this->getDb()->query( $sql );
}

if( count( $res ) )
if( $res )
{
$output = array();

Expand All @@ -584,7 +565,7 @@ public function findBySql()
return $output;
}

return null;
return [];
}


Expand Down

0 comments on commit 580e3ef

Please sign in to comment.