Wednesday, November 14, 2012

varchars as foreign keys in Cake leads to conversion to Int Error - using MS SQL

Hi!!
I work ussualy with mysql and I work in cake long time, but now with MS SQL, I get strange error on very simple thing - view, index, edit methods within SCAFFOLD mode.

Error: 
SQLSTATE[22018]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Conversion failed when converting the varchar value 'G12345' to data type int.

There is a table called 'item', which has a field GLID - vachar(20). Simple field, not even primary key. the only thing is that it is in relation with other table 'material' with same properties. E.g. 'item' hasMany 'material' AND 'material' belongsTo 'item'.

Can I link varchars as foreign keys in cake?? Because if I edit the field values and I remove letter 'G' ... 'G12345' >> '12345' then it works ok!! why cake converts something to int??


Any idea?

Thank you
Tomas

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: