Thursday, January 29, 2009

Problems using Set::matches and XPATH expression

Hey guys,

I'd like to use the Set::matches function as explained in the CakePHP
1.2 book on http://book.cakephp.org/view/670/matches to check the
existance of a value within an array.

I did not get it to work within my application so I tried the examples
directly from the page and it did not work either.
I'm using the cake 1.2.1.8004

Here's the snippet I copied:

$a = array(
array('Article' => array('id' => 1, 'title' => 'Article 1')),
array('Article' => array('id' => 2, 'title' => 'Article 2')),
array('Article' => array('id' => 3, 'title' => 'Article 3')));
$res=Set::matches('/Article[id=2]', $a);
// returns true

The returned value of $res is alway FALSE when I tested it. I took a
look inside the set.php shipped with cakePHP 1.2.1.8004 and he
returned false within the following part: (line 543-546)

list(,$key,$op,$expected) = $match;
if (!isset($data[$key])) {
return false;
}

Any ideas? Thanks for all help!
--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: