Thanks AD7six, i also tried it in my previous test but Cake never
render the page, it seems to make a loop and it fails with this error:

Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp
\htdocs\MyAppName\trunk\lib\Cake\Model\Datasource\DboSource.php on
line 1436


        var $belongsTo = array(
                        'Wdevice' => array(
                                                                'className' => 
'Wdevice',
                                                                'foreignKey' => 
false,
                                                                'conditions' => 
array('Wdevice.device_mac =
Radpostauth.username')

                        )
        );

If i do the SQL query in phpMyAdmin it works correctly:

Mostrando registros 0 - 29 ( 50 total, La consulta tardó 0.2787 seg)
[id: 20179 - 20130]
(Sorry for the Spanish)

SELECT  `Radpostauth`.`id` ,  `Radpostauth`.`username` ,
`Radpostauth`.`pass` ,  `Radpostauth`.`reply` ,
`Radpostauth`.`authdate` ,  `Wdevice`.`id` ,
`Wdevice`.`wcontract_id` ,  `Wdevice`.`device_mac` ,
`Wdevice`.`wdevices_model_id` ,  `Wdevice`.`created` ,
`Wdevice`.`modified`
FROM  `radpostauth` AS  `Radpostauth`
LEFT JOIN  `wdevices` AS  `Wdevice` ON (  `Wdevice`.`device_mac` =
`Radpostauth`.`username` )
WHERE 1 =1
ORDER BY  `Radpostauth`.`id` DESC
LIMIT 50

And if i write:
                                                                'conditions' => 
array('Wdevice.device_mac =
Radpostauth.username' => '')

It works (don't enter in a loop) but the query fails:

SELECT  `Radpostauth`.`id` ,  `Radpostauth`.`username` ,
`Radpostauth`.`pass` ,  `Radpostauth`.`reply` ,
`Radpostauth`.`authdate` ,  `Wdevice`.`id` ,
`Wdevice`.`wcontract_id` ,  `Wdevice`.`device_mac` ,
`Wdevice`.`wdevices_model_id` ,  `Wdevice`.`created` ,
`Wdevice`.`modified`
FROM  `radpostauth` AS  `Radpostauth`
LEFT JOIN  `wdevices` AS  `Wdevice` ON (  `Wdevice`.`device_mac` =
`Radpostauth`.`username` '') // <- note the ( '' )
WHERE 1 =1
ORDER BY  `Radpostauth`.`id` DESC
LIMIT 50

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near ''') WHERE 1 = 1
ORDER BY `Radpostauth`.`id` desc LIMIT 50' at line 1

So i don't know what to do now : (

Thanks for your help guys : )

On 3 ene, 12:19, AD7six <andydawso...@gmail.com> wrote:
> On Jan 3, 11:23 am, Cristian Deluxe <djcristiandel...@gmail.com>
> wrote:
>
> > Hey thanks : )
>
> > I've tried this but seems like CakePHP doesn't parse the condition
> > correctly:
>
> >         var $belongsTo = array(
> >                         'Wdevice' => array(
> >                                                                 'className' 
> > => 'Wdevice',
> >                                                                 
> > 'foreignKey' => false,
> >                                                                 
> > 'conditions' => array('Wdevice.device_mac' =>
> > 'Radpostauth.username')
>
> If the above did what you wanted cake would be rife with sql injection
> problems. Thankfully it does exactly what you asked and tests where
> device_mac = the string you've typed in the conditions.
>
> You want
> array('Wdevice.device_mac = Radpostauth.username')
>
> probably.
>
> AD

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to