My Yii Turns Upside Down Giving Ambiguous Parameter Error When Saving Model

Hi all,

I don’t know what’s going on with my Yii app… yesterday it works well but today, I didn’t touch many things but when yii tries to insert something in DB I have an exception :

CDbCommand failed to execute the SQL statement: SQLSTATE[42P08]: Ambiguous parameter: 7 ERROR: inconsistent types deduced for parameter $1

LINE 1: …x", "sport", "age") VALUES ($1, $1, $1, $1…

^

DETAIL: text versus boolean. The SQL statement executed was: INSERT INTO “ConfigInterfaceProfile” (“name”, “sex”, “sports”, “age”) VALUES (:yp0, :yp0, :yp0, :yp0). Bound with :yp0=‘0’

This coming from “save()” function… I have this error with all of my controller… 2h I’m working on :’(

Pleas help =)

Update seems to work though

it seems you are trying to store the same values…with $1

lol… Thanks for you reply but… If I post a topic here it’s because there is a problem… for sure I’m not typing the same value in all fields and $1 is probably set by postgresql itself… but I don’t understand why…

Problem seemed to come from CDbCommandBuilder, in :


public function createInsertCommand($table,$data)

	{

		$this->ensureTable($table);

		$fields=array();

		$values=array();

		$placeholders=array();

		$i=0;

		foreach($data as $name=>$value)

		{

			if(($column=$table->getColumn($name))!==null && ($value!==null || $column->allowNull))

			{

				$fields[]=$column->rawName;

				if($value instanceof CDbExpression)

				{

					$placeholders[]=$value->expression;

					foreach($value->params as $n=>$v)

						$values[$n]=$v;

				}

				else

				{

					$placeholders[]=self::PARAM_PREFIX.$i;

					if($column->dbType==='boolean')						//KLUDGE

						$values[self::PARAM_PREFIX.$i]=(string)$value;	// fixtures can now use boolean 'true' and 'false'

					else												//

						$values[self::PARAM_PREFIX.$i]=$column->typecast($value);

				}

			}

      [b]$i++;[/b]

		}

...

There was no incrementation of $i… I don’t really understand how it could work without before O_o because I checked out my svn and there was no change for a long time

Check the actual source (click on show) - http://www.yiiframew…tCommand-detail

Seems you are using a custom version (checking for "boolean") and there should go the missing $i++

Yep I edited the file because this problem between postgresql, boolean type and yii (or generally php maybe) is famous and not resolve. Then modifying it, I removed inadvertently the $i++. However I did that 4 months ago (checking svn)… and I’m surprised it started to not work only monday…

Anyway, it’s working now.

thanks