Hi all,

I'm having multiple problems using non numeric index with Mysql and
CakePHP 1.2, specifically when it reaches a index that is a pure
number -- AFAIK, cakephp supports non numeric index.

Example: I have this table using a non numeric index:

id* (varchar)     |  foo (varchar)
========
xpto  | null
9abc | null
9 | null

It works perfectly while making operations for the items with
id='xpto' and id='9abc', but it will not work while dealing with the
id='9' item due cakephp will use 9 instead of '9' in Mysql queries
that will take item id='9abc' too.

Here are the problems that I'm facing:

1) If I try to count the elements with id='9' it will tell me 2
instead of 1:
                $id = '9';
                $conditions = array('id' => $id);
                $count = $this->NonNumericIndexTest->find('count',
array('conditions' => $conditions));
//it will produce a $count = 2 instead of 1  due it will consider
id='9abc'  item too.

2) if I try to update item with id='9', it will update id='9abc' data
too
                $id = '9';
                $fields = array('foo'=>"'this should be for id=9 only'");
                $conditions = array('id' => $id);
                $this->NonNumericIndexTest->updateAll($fields, $conditions);
//it will update id='9abc' data too.


3) It will not allow to update id='9' data using save() due exists a
id='9abc':
                $data = array();
                $data['NonNumericIndex'] = array ('id' => '9',
                                                'foo' => "'This will never be 
saved due already exists a id=9abc
and id=9'");
                $result = $this->NonNumericIndexTest->save($data, false);
// This will produce a $result=false and no data will be updated

4) If I try to delete id='9' item, id='9abc' will be gone too.
          $this->NonNumericIndexTest->delete('9');
// items id='9' and id='9abc' are gone.

There is workarounds for item (1) for example using literal conditions
like: "`id` =  '$id'"  but I don't know how to make item (3) work.

I tested it on cake 1.2 beta (6311) and svn (6609) but for both
versions  all 4 cases  failed.

Am I doing something very wrong or this is really a bug? I prepared
some test cases and I'm thinking in issue a bug on trac for this.

...please so not suggest to use numerical index - this is not an
option for me right now.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to