Re: frustrating redirect issue

2014-11-12 Thread 'Benjamin Chéré' via CakePHP


Try to debug the redirect in the AppController::beforeFilter() 
: http://stackoverflow.com/questions/2404977/debugging-a-browser-redirect-loop

Le mardi 11 novembre 2014 12:43:17 UTC+1, Δημήτρης Κρεμμύδας a écrit :
>
> I have made this simple view-less action on a controller 
>
> function lala($id=null) { $this->redirect('http://google.com',null,false
> );}
>
>
> and I get a redirecting loop (to controller/lala).
>
> If I write the function as
>
> function lala($id=null) { pr('ok');die;}
>
> then it prints 'ok' and then complains that there is no view.
>
> any ideas ?
>
>
>
>
> ps1. I use 1.3.20
> ps2. the isAuthorized is set to always 'return true'
>
>
>
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Validate if not between

2013-11-19 Thread Benjamin Chéré
Hello,
I think it's not a validation rule, your query is a search condition

$this->Publisher->find ('all', array(

'fields' => array('pub_name', 'country', 'pub_city', 'estd'),

'conditions' => array('OR'=>array('YEAR(estd) <' => 2010, 'YEAR(estd) >' => 
2013))

)); 


Le lundi 18 novembre 2013 23:38:35 UTC+1, Salines a écrit :
>
> Hi, folks
>
>
> Is there any validation rules that check sent data does not exist between 
> two dates? Or need to make a custom validation method?
>
> If there is no data between two dates validation must return TRUE or FALSE 
> if it exists.
>
> Syntax as follows
> SELECT pub_name, country, pub_city, estd
> FROM publisher
> WHERE YEAR (estd) NOT BETWEEN 2010 AND 2013;
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Re: mysql join query gives too much results, twice.

2013-10-16 Thread Benjamin Chéré
Hi,

To have the categories of a product, I would search from Product model.
If recursive = 1 the associated categories would be in the result.
$this->Category->Product->find('first', array(

'conditions' => array('Product.id'=>$pid)

));

Or you can use Containable behavior to control what you want in the result.
You have in your Product model :
public $actsAs = array('Containable');
public $hasAndBelongsToMany = array(

'Category' => array(

'className' => 'Category',
'joinTable' => 'cat_connect',
'foreignKey' => 'product_id', 

'associationForeignKey'  => 'category_id', 

) 

 );

to find the categories from the Controller :
$this->Product->find('first', array(

'conditions' => array('Product.id'=>$pid),

'contain' => array('Category.name')

));

sorry if I have not answered the question,
hope this helps

BenJ

Le mardi 15 octobre 2013 11:48:40 UTC+2, UltraMarkus a écrit :
>
> Hi,
>  
> As im new to this group, i first want to apologize for my bad english. 
> Just starded to use cakePHP 2 weeks ago, and i must say, great work!!! I 
> managed to get my things to be done and Im gratefull for excistence of it.
>  
> But hey, now im stuck with my query, and believe me, i searched a lot. 
> However, I might not understand what Im doing or it's just a hard trick.
>  
> Here is my query:
>  
> $this->set('categorienAdded', $this->Categorie->find('all',array('joins' 
> => array(
> array(
> 'table' => 'categories',
> 'alias' => 'cat',
> 'type' => 'inner',
> 'foreignKey' => false,
>   'conditions'=> array('')
> ),
> array(
> 'table' => 'cat_connects',
> 'alias' => 'cat_con',
> 'type' => 'inner',
> 'foreignKey' => false,
> 'conditions'=> array(
>'cat.id = cat_con.categorie_id',
> 'cat_con.product_id' => $pid)
> )
> )
> )));
>  
> My tables are :
>  
>  cat_connect:
>  
>  id  product_id  categorie_id
>  1   65   4
>  2   64   2
>  3   64   1
>  
>  categories:
>  
>  id  naam
>  1   Categorie 1
>  2   Test 
>  3   Work
>  4   Temp
>  
>  
> As my $pid = 64 I whould like to have only 'Categorie 1'  and  'Test' in 
> my result. However, i get all Names twice. How should i build my query?
>  
>  
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.