Commit 598d0128 by Carsten Brandt

added cubrid specific pdo type casting

cubrid pdo does not support PARAM_BOOL so we cast the value to integer and store 0 and 1 instead fixes #964
parent 32865c7d
...@@ -237,4 +237,24 @@ class Schema extends \yii\db\Schema ...@@ -237,4 +237,24 @@ class Schema extends \yii\db\Schema
} }
return $tableNames; return $tableNames;
} }
/**
* Determines the PDO type for the given PHP data value.
* @param mixed $data the data whose PDO type is to be determined
* @return integer the PDO type
* @see http://www.php.net/manual/en/pdo.constants.php
*/
public function getPdoType($data)
{
static $typeMap = array(
// php type => PDO type
'boolean' => \PDO::PARAM_INT, // PARAM_BOOL is not supported by CUBRID PDO
'integer' => \PDO::PARAM_INT,
'string' => \PDO::PARAM_STR,
'resource' => \PDO::PARAM_LOB,
'NULL' => \PDO::PARAM_NULL,
);
$type = gettype($data);
return isset($typeMap[$type]) ? $typeMap[$type] : \PDO::PARAM_STR;
}
} }
...@@ -32,5 +32,11 @@ class CubridActiveRecordTest extends ActiveRecordTest ...@@ -32,5 +32,11 @@ class CubridActiveRecordTest extends ActiveRecordTest
$customer->refresh(); $customer->refresh();
$this->assertEquals(0, $customer->status); $this->assertEquals(0, $customer->status);
$customers = Customer::find()->where(array('status' => true))->all();
$this->assertEquals(2, count($customers));
$customers = Customer::find()->where(array('status' => false))->all();
$this->assertEquals(1, count($customers));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment