[Solved] How to custom save an AR field

[SOLVED] Hi, I’ve just tried to ask for help in the Spanish forum but I’ll try here to because I’m in a hurry, so, sorry for my English ;)

I have a class called zone that is not an AR because there is a field of type Polygon and it seems that it must be managed manually, so, what I want is to use an AR for this class but have to read this field manually, the same for the insert and update. Can you give some tips? Can I do this operations in the same accesses to the db that Yii does?

This is the way the polygon has to be read from the db:

select … "AsText(poligono) as poligono" …

And to write it to the db:

insert/update … ‘POLYGON((-38.011067436808 -57.553310960449,-38.020534366999 -57.561035722412,-38.030000074349 -57.541466325439,-38.010661683903 -57.54198130957,-38.011067436808 -57.553310960449))’…

Well, sorry about my English again, I hope you understand the issue.

Thanks in advance.

Juan

Hi, I tried to set the polygon field in the beforeSave but this is what I get:




Error in executing SQL: UPDATE `zona` SET `id`=:yp0, `poligono`=:yp1,

`nombre`=:yp2, `descripcion`=:yp3, `precioEnvio`=:yp4, `proveedor_id`=:yp5

WHERE `zona`.`id`='36'. Bound with :yp0='36',

:yp1='geomFromText("POLYGON((-38.011067436808

-57.553310960449,-38.020534366999 -57.561035722412,-38.030000074349

-57.541466325439,-38.010661683903 -57.54198130957,-38.011067436808

-57.553310960449))")', :yp2='xxx', :yp3='Maecenas semper pellentesque

tortor, at gravida massa molestie nec. Vestibulum sollicitudin sollicitudin

fermentum? Quisque commodo, leo nec mattis tempor, sem lacus interdum

tellus, eget tincidunt nisl est fringilla sem. Pellentesque blandit

tincidunt iaculis. Etiam aliquet lacus sit amet augue sollicitudin cras

amet.

', :yp4='10', :yp5='1'



If I update in the db by hand it works, buy something is happening between the beforesave and the update, don’t know where to see.

Solved, thanks to Sebas ;), I used CDbExpression and worked perfectly