Help with Finder

2012-04-05 Thread ingcara
Morning Bakers

I have the following case: In my application I have a search engine,
which you enter your email or name, it searches for registered users
to these criteria. The problem is that instead of a text input area, I
want to make a selection with SELECT, so the user does not have to
type anything, moreover wanted to have the same form a SELECT list of
options that will be added and show Users with these criteria.

I've tried everything, but unfortunately not able to make it work. Who
can help thanks.

The application works like this: The search criteria are in VIEW
Busca_a, and Pequisar pressing the button, this button calls the
function search () in controller and VIEW search.


The function in my CONTROLLER

function usuario_busca() {

$this-set('meuPerfil', 1);
if(!empty($this-data['tipo']) AND 
!empty($this-data['valor'])) {
switch($this-data['tipo']) {
case 'nome':

$dados = 
$this-Usuario-find('all',
array('conditions'=array('or'=array(

'sexualidade_usuario'=$this-data['valor'],
'nome_usuario 
LIKE'='%'.$this-data['valor'].'%',
'nascimento_usuario 
LIKE'='%'.$this-data['valor'],

'email_usuario'=$this-data['valor'] ,

'descricao_usuario'=$this-data['valor'],

'culinaria_usuario'=$this-data['valor'],

'altura_usuario'=$this-data['valor'],

'relacionamento_usuario'=$this-data['valor'],

'paixao_usuario'=$this-data['valor'])),

'order'=array('nome_usuario 
ASC'), 'limit'=200));

break;
default: break;
}

if(isset($dados) AND !empty($dados)) 
$this-set('dados', $dados);
$busca = array('valor'= $this-data['valor']);
$this-set('busca', $busca);
}
else $this-redirect($this-site['url']['site'] . 'usuario/rede/
perfil');
}





THE  VIEWs

VIEW BUSCA_A


form action=?php echo $site['url']['site'] ?usuario/rede/busca
method=post class=form busca


label for=nome_contatoQual é o numero de sua 
escolha:/label
input type=text id=nome_contato name=data[valor] 
/
input type=hidden name=data[tipo] value=nome /





button class=botao_1 botao_1_1 type=submit
title=PesquisarPesquisar/button

button class=botao_1 botao_1_1 type=reset
title=Limpar BuscaLimpar Busca/button




/form/ul/div






USUARIO BUSCA()

?php
$this-pageTitle = 'REDE: Resultado da busca para ' . $busca['valor'];
echo $this-element('barralateral');
?

div id=pag-rede-busca class=conteudo rede
?php $msgAlerta = $session-flash(); if(!empty($msgAlerta)) echo
'div class=alerta_1 alerta_1_1' . $msgAlerta . '/div'; ?

div class=box_e
?php
$img = (!empty($usuarioON['imagem_usuario'])) ? 
'upload/usuarios/
escala/' . $usuarioON['imagem_usuario'] : 'usuario.jpg';
echo 'img src=' . $site['url']['prefix'] . 'img/' . $img . '
alt=' . $usuarioON['nome_usuario'] . ' title=' .
$usuarioON['nome_usuario'] . ' width=175 /';
echo $this-element('lateralrede');
?
/div

div class=box_d
h2Resultados da busca para: span class=db?php echo
$busca['valor'] ?/span/h2

div class=conteudo
?php if(isset($dados) AND !empty($dados)): ?
ul class=produtos
?php
foreach($dados as $item):
$item = $item['Usuario'];

$nomePart = explode(' ', 
$item['nome_usuario']);
$nome = $nomePart[0];
if(isset($nomePart[1]) AND 
!empty($nomePart[1])) $nome .= ' ' .
$nomePart[1];
?
   

Re: Problems with Find ('all')

2012-03-29 Thread ingcara
Thanks Marcus, I tried another way and its working now:

$dados = $this-Usuario-find('all',
array('conditions'=array('or'=array(
'nome_usuario 
LIKE'='%'.$this-data['valor'].'%',
'nascimento_usuario 
LIKE'='%'.$this-data['valor'],

'email_usuario'=$this-data['valor'] ,

'relacionamento_usuario'=$this-data['valor'],

'paixao_usuario'=$this-data['valor'])),
'order'=array('nome_usuario 
ASC'), 'limit'=100));

Thanks for your help!!!

On 28 mar, 09:43, Marcus James marco...@gmail.com wrote:
 Hi,

 I think your condition clause is not properly written.

 Try this

 $dados = $this-Usuario-find('all', array('conditions'=array(
                                        'OR'=array(array('nome_usuario
 LIKE'='%'.$this-data['valor'].'%',
 'ocupacao_usuario'=$this-data['valor']),array('religiao_usuario'=$this- 
 data['valor']),array('email_usuario'=$this-data['valor']);

 Enjoy,

 Marcus

-- 
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


Problems with Find ('all')

2012-03-28 Thread ingcara

Hello everyone,

I need a help with a issue. I´m trying to add another condition to my
Search Function (usuario_busca).

This is the Code in the Controller:

function usuario_busca() {

$this-set('meuPerfil', 1);



if(!empty($this-data['tipo']) AND 
!empty($this-data['valor'])) {

switch($this-data['tipo']) {

case 'nome':

$dados = $this-Usuario-find('all', 
array('conditions'=array(
'or'=array('nome_usuario 
LIKE'='%'.$this-
data['valor'].'%','email_usuario'=$this-data['valor'])),
 'order'=array('descricao_usuario 
ASC'), 'limit'=100));

break;

default: break;

}


if(isset($dados) AND !empty($dados)) 
$this-set('dados', $dados);

$busca = array('valor'= $this-data['valor']);

$this-set('busca', $busca);

}

else $this-redirect($this-site['url']['site'] . 'usuario/rede/
perfil');

}

}



?

When i entered the value of email or any name, cake retrieve the info
succesfully, but when I try to add more conditions or structures of
the tables and I entered the value throug the View == Nothing
Happend , for example

$dados = $this-Usuario-find('all', array('conditions'=array(
'or'=array('nome_usuario 
LIKE'='%'.$this-data['valor'].'%',
'ocupacao_usuario'=$this-data['valor'])),  'religiao_usuario'=$this-
data['valor'])), 'email_usuario'=$this-data['valor'])),
 'order'=array('descricao_usuario 
ASC'), 'limit'=100));

I will appreciate if someone can help me.



-- 
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