Problem with something like max field length?

Hi guys,

I’m facing a problem with the length of strings right now.

There is a column in my database that may contain quite long strings. When I let gii generate the model, he set the [font="Courier New"]rules()[/font] to


array('VALUE', 'length', 'max'=>2500),

In the model I wrote a static function that is supposed to return the field’s value of a particular row:




	public static function getValueString($id)

	{

		$report = CurrentController::model()->findall("something = '$id'");

		foreach ($report AS $elem)

		{

			if($elem->NAME == 'foo') return = $elem->VALUE;

		}

	}



Now I’d like to have a look at this in a view:


array('label'=>'Description','type'=>'raw', 'value'=>CurrentController::getValueString($foo[$x]->NR)),

What I get is not the entire string, it’s just the beginning of it.


echo strlen(CurrentController::getValueString($foo[$x]->NR));

tells me it’s length is 255 chars.

First, I suspected PHP or my DB-Driver (FreeTDS -> MsSQL 2008), but writing a quick pure-PHP-test ensured they all were be fine and they were showing the correct ~600 chars string.

Does anyone know where the problem might be? Is it possible to tell yii, the column is not a max-255-chars-VARCHAR but more something like a TEXT?

Thanks for any help

Solved.

Seems FreeTDS can only handle varchars up to 255 chars and uses this datatype automatically.

Converting the type in the query like this resolves the issue:


SELECT CAST(column as TEXT) FROM table