Skip to content

Commit

Permalink
[update] Code improve
Browse files Browse the repository at this point in the history
  • Loading branch information
catfan committed Feb 9, 2015
1 parent a124a1c commit 13ee8c7
Showing 1 changed file with 25 additions and 32 deletions.
57 changes: 25 additions & 32 deletions medoo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* http://medoo.in
* Version 0.9.7
*
* Copyright 2015, Angel Lai
* Copyright 2014, Angel Lai
* Released under the MIT license
*/
class medoo
Expand Down Expand Up @@ -384,35 +384,28 @@ protected function data_implode($data, $conjunctor, $outer_conjunctor = null)
}
else
{
if (is_int($key))
switch ($type)
{
$wheres[] = $this->quote($value);
}
else
{
switch ($type)
{
case 'NULL':
$wheres[] = $column . ' IS NULL';
break;

case 'array':
$wheres[] = $column . ' IN (' . $this->array_quote($value) . ')';
break;

case 'integer':
case 'double':
$wheres[] = $column . ' = ' . $value;
break;

case 'boolean':
$wheres[] = $column . ' = ' . ($value ? '1' : '0');
break;

case 'string':
$wheres[] = $column . ' = ' . $this->fn_quote($key, $value);
break;
}
case 'NULL':
$wheres[] = $column . ' IS NULL';
break;

case 'array':
$wheres[] = $column . ' IN (' . $this->array_quote($value) . ')';
break;

case 'integer':
case 'double':
$wheres[] = $column . ' = ' . $value;
break;

case 'boolean':
$wheres[] = $column . ' = ' . ($value ? '1' : '0');
break;

case 'string':
$wheres[] = $column . ' = ' . $this->fn_quote($key, $value);
break;
}
}
}
Expand Down Expand Up @@ -742,9 +735,9 @@ public function update($table, $data, $where = null)
case 'array':
preg_match("/\(JSON\)\s*([\w]+)/i", $key, $column_match);

$fields[] = isset($column_match[0]) ?
$this->column_quote($column_match[1]) . ' = ' . $this->quote(json_encode($value)) :
$column . ' = ' . $this->quote(serialize($value));
$fields[] = $column . ' = ' . $this->quote(
isset($column_match[0]) ? json_encode($value) : serialize($value)
);
break;

case 'boolean':
Expand Down

0 comments on commit 13ee8c7

Please sign in to comment.