Yii Framework Forum: Boolean type in sql as integer - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Boolean type in sql as integer AR generates sql with integer except of boolean Rate Topic: -----

#1 User is offline   JoK3R 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 26-July 12

Posted 26 July 2012 - 06:15 PM

Hello. After loading model with AR and saving it (nothing changed) i have CDbException:
Error: column "x" is of type boolean but expression is of type integer

$model = MyModel::model()->findByPk($id);
$model->save();


and

$model = MyModel::model()->findByPk($id);
if($model->x)
  $model->x = 'true';
else
  $model->x = 'false';
$model->save();

works

Yii: v1.1.10
PHP: 5.4
Postgresql: 9.1.4

At the host with PHP 5.3 and Postgresql 8.2 there are any probles with it;
0

#2 User is offline   JoK3R 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 26-July 12

Posted 26 July 2012 - 07:45 PM

So, it's a strange bug.
I've made fix in CDbConnection
			//'boolean'=>PDO::PARAM_BOOL,
                        'boolean'=>PDO::PARAM_STR,


And now it's work good.

But
$sql = 'update xxx set ttt = :yyy where id = :zzz';
$s = $db->prepare($sql);
$val = 1;
$s->bindParam(':yyy',$val);
$s->bindParam(':zzz',$val,PDO::PARAM_INT);
$s->execute();


Generates 't'

and
$sql = 'update xxx set ttt = :yyy where id = :zzz';
$s = $db->prepare($sql);
$val = 1;
$s->bindParam(':yyy',$val, PDO::PARAM_BOOL);
$s->bindParam(':zzz',$val,PDO::PARAM_INT);
$s->execute();


Also generates 't'.

So it's a PDO bug or Yii bug?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users