Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
catfan committed Mar 26, 2018
2 parents 4e51f74 + 4b29403 commit f77a93f
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/Medoo.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*!
* Medoo database framework
* https://medoo.in
* Version 1.5.5
* Version 1.5.6
*
* Copyright 2018, Angel Lai
* Released under the MIT license
Expand Down Expand Up @@ -541,7 +541,7 @@ protected function dataImplode($data, &$map, $conjunctor)

if (
is_int($key) &&
preg_match('/([a-zA-Z0-9_\.]+)\[(?<operator>\>\=?|\<\=?|\!|\=)\]([a-zA-Z0-9_\.]+)/i', $value, $match)
preg_match('/([a-zA-Z0-9_\.]+)\[(?<operator>\>\=?|\<\=?|\!?\=)\]([a-zA-Z0-9_\.]+)/i', $value, $match)
)
{
$stack[] = $this->columnQuote($match[ 1 ]) . ' ' . $match[ 'operator' ] . ' ' . $this->columnQuote($match[ 3 ]);
Expand Down Expand Up @@ -1003,7 +1003,7 @@ protected function selectContext($table, &$map, $join, &$columns = null, $where
}
else
{
if (empty($columns))
if (empty($columns) || $this->isRaw($columns))
{
$columns = '*';
$where = $join;
Expand Down Expand Up @@ -1082,43 +1082,51 @@ protected function dataMap($data, $columns, $column_map, &$stack)

$column_key = $map[ 0 ];

$result = $data[ $column_key ];

if (isset($map[ 1 ]))
{
if ($isRaw && in_array($map[ 1 ], ['Object', 'JSON']))
{
continue;
}

if (is_null($result))
{
$stack[ $column_key ] = null;
continue;
}

switch ($map[ 1 ])
{
case 'Number':
$stack[ $column_key ] = (double) $data[ $column_key ];
$stack[ $column_key ] = (double) $result;
break;

case 'Int':
$stack[ $column_key ] = (int) $data[ $column_key ];
$stack[ $column_key ] = (int) $result;
break;

case 'Bool':
$stack[ $column_key ] = (bool) $data[ $column_key ];
$stack[ $column_key ] = (bool) $result;
break;

case 'Object':
$stack[ $column_key ] = unserialize($data[ $column_key ]);
$stack[ $column_key ] = unserialize($result);
break;

case 'JSON':
$stack[ $column_key ] = json_decode($data[ $column_key ], true);
$stack[ $column_key ] = json_decode($result, true);
break;

case 'String':
$stack[ $column_key ] = $data[ $column_key ];
$stack[ $column_key ] = $result;
break;
}
}
else
{
$stack[ $column_key ] = $data[ $column_key ];
$stack[ $column_key ] = $result;
}
}
else
Expand Down

0 comments on commit f77a93f

Please sign in to comment.