Permalink
Browse files

Added missing variable type for boolean.

  • Loading branch information...
Stardog committed Nov 20, 2017
1 parent 2b7c997 commit f1cf850b428fe26674f80be63dc761ffa619ef95
Showing with 19 additions and 7 deletions.
  1. +19 −7 src-phpws2/src/Database/Value.php
@@ -24,7 +24,8 @@ class Value extends Column
* @param string $name
* @param string $value
*/
public function __construct(Table $table, $name, $value = null, $check_existence = null)
public function __construct(Table $table, $name, $value = null,
$check_existence = null)
{
parent::__construct($table, $name, $check_existence);
$this->set($value);
@@ -39,17 +40,20 @@ public function set($value)
{
switch (\gettype($value)) {
case 'string':
$this->value = new \phpws2\Variable\StringVar($value, $this->name);
$this->value = new \phpws2\Variable\StringVar($value,
$this->name);
return true;
break;
case 'integer':
$this->value = new \phpws2\Variable\IntegerVar($value, $this->name);
$this->value = new \phpws2\Variable\IntegerVar($value,
$this->name);
return true;
break;
case 'double':
$this->value = new \phpws2\Variable\DoubleVar($value, $this->name);
$this->value = new \phpws2\Variable\DoubleVar($value,
$this->name);
return true;
break;
@@ -71,13 +75,20 @@ public function set($value)
//} elseif (method_exists($value, '__toString')) {
//$this->value = new \phpws2\Variable\StringVar($value->__toString(), $this->name);
} else {
throw new \Exception(sprintf('Unacceptable value type (%s)', gettype($value)));
throw new \Exception(sprintf('Unacceptable value type (%s)',
gettype($value)));
}
return true;
break;
case 'array':
$this->value = new \phpws2\Variable\StringVar(serialize($value), $this->name);
$this->value = new \phpws2\Variable\StringVar(serialize($value),
$this->name);
return true;
break;
case 'boolean':
$this->value = $value ? 1 : 0;
return true;
break;
@@ -86,7 +97,8 @@ public function set($value)
return true;
break;
}
throw new \Exception(sprintf('Unacceptable value type (%s)', gettype($value)));
throw new \Exception(sprintf('Unacceptable value type (%s)',
gettype($value)));
}
/**

0 comments on commit f1cf850

Please sign in to comment.