[symfony-users] Configure HYDRATATION mode for doctrine

2010-06-14 Thread jdeveloper
Hy

Can someone tell me what is the default hydratetion mode for doctrine
in symfony and how can I change it?

Thanks

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Integrate log4j with symfony

2010-08-26 Thread jdeveloper
Hi

I would like to know if there is a way to integrate log4j with symfony
since log4j has a powerfull configuration options?

Thanks

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Escape quote on FormFilter

2010-09-08 Thread jdeveloper
Hi

I have a little problem in implementing a form filter using doctrine.

The problem is that I need to filter fields belonging to an related
table. So I create cutom addXColumnQuery methods:

public function  addPnombreColumnQuery(Doctrine_Query $query, $field,
$value) {
$this->addPersonaTableTextFiledFilter($query,'pnombre',
$value);
}

public function  addPapellidosColumnQuery(Doctrine_Query $query,
$field, $value) {
$this->addPersonaTableTextFiledFilter($query,'papellidos',
$value);
}

public function  addPdniColumnQuery(Doctrine_Query $query, $field,
$value) {
$this->addPersonaTableTextFiledFilter($query,'pdni',$value);
}

protected function addPersonaTableTextFiledFilter(Doctrine_Query
$query, $field, $value){
if(!$this->personaTableJoined){
$rootAlias = $query->getRootAlias();

$query->innerJoin($rootAlias.'.Persona p');
$this->personaTableJoined = true;
}


$query->andWhere('p.'.$field.' LIKE ?','%'.$value.'%');
}

It works well except when the text has quotes. They are not escaped
automaticly.

I'm using symfony 1.4 with mysql and my database connection
configuretion looks like this:

all:
  doctrine:
class: sfDoctrineDatabase
param:
  dsn: 'mysql:host=host;dbname=name'
  username: user
  password: password

I found a little solution that I don't like very well:

protected function addPersonaTableTextFiledFilter(Doctrine_Query
$query, $field, $value){
if(!$this->personaTableJoined){
$rootAlias = $query->getRootAlias();

$query->innerJoin($rootAlias.'.Persona p');
$this->personaTableJoined = true;
}

$quotedValue = $query->getConnection()->getDbh()->quote('%'.
$value.'%', PDO::PARAM_STR); //escape quotes

$query->andWhere('p.'.$field.' LIKE '.$quotedValue);
}

Is there any better solution? I think the autogenerated filter form o
symfony have the same problem but I'm no sure.

regards

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Removing a field from a form in an action

2010-09-08 Thread jdeveloper
I think you could pass the user as an option in the constructor, and
than unset it in the configure method.

Hope it helps

On Sep 8, 4:31 pm, torok84  wrote:
> Hi,
>
> I have a form to select some search options. I have a field that I
> wanto to show only if the user is logged in. I want to do something
> like this:
>
> if(!$this->getUser()->hasAttribute('user'))
>       unset($this->form->widgetSchema['mine']);
>
> that doesn't work because widgetSchema is protected. Moreover doing
> this would leave a dangling validator for the 'mine' field. I
> undestand I can create a second form class without the 'mine' field,
> but it would be nice if I could simply unset a field.
>
> Thanks
> Paolo

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Removing a field from a form in an action

2010-09-08 Thread jdeveloper
I think you could pass the user as an option in the constructor, and
than unset it in the configure method.

Hope it helps

On Sep 8, 4:31 pm, torok84  wrote:
> Hi,
>
> I have a form to select some search options. I have a field that I
> wanto to show only if the user is logged in. I want to do something
> like this:
>
> if(!$this->getUser()->hasAttribute('user'))
>       unset($this->form->widgetSchema['mine']);
>
> that doesn't work because widgetSchema is protected. Moreover doing
> this would leave a dangling validator for the 'mine' field. I
> undestand I can create a second form class without the 'mine' field,
> but it would be nice if I could simply unset a field.
>
> Thanks
> Paolo

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Re: Escape quote on FormFilter

2010-09-09 Thread jdeveloper
Anyone knows a beter way?

On Sep 8, 4:40 pm, jdeveloper  wrote:
> Hi
>
> I have a little problem in implementing a form filter using doctrine.
>
> The problem is that I need to filter fields belonging to an related
> table. So I create cutom addXColumnQuery methods:
>
> public function  addPnombreColumnQuery(Doctrine_Query $query, $field,
> $value) {
>         $this->addPersonaTableTextFiledFilter($query,'pnombre',
> $value);
>     }
>
>     public function  addPapellidosColumnQuery(Doctrine_Query $query,
> $field, $value) {
>         $this->addPersonaTableTextFiledFilter($query,'papellidos',
> $value);
>     }
>
>     public function  addPdniColumnQuery(Doctrine_Query $query, $field,
> $value) {
>         $this->addPersonaTableTextFiledFilter($query,'pdni',$value);
>     }
>
>     protected function addPersonaTableTextFiledFilter(Doctrine_Query
> $query, $field, $value){
>         if(!$this->personaTableJoined){
>             $rootAlias = $query->getRootAlias();
>
>             $query->innerJoin($rootAlias.'.Persona p');
>             $this->personaTableJoined = true;
>         }
>
>         $query->andWhere('p.'.$field.' LIKE ?','%'.$value.'%');
>     }
>
> It works well except when the text has quotes. They are not escaped
> automaticly.
>
> I'm using symfony 1.4 with mysql and my database connection
> configuretion looks like this:
>
> all:
>   doctrine:
>     class: sfDoctrineDatabase
>     param:
>       dsn: 'mysql:host=host;dbname=name'
>       username: user
>       password: password
>
> I found a little solution that I don't like very well:
>
> protected function addPersonaTableTextFiledFilter(Doctrine_Query
> $query, $field, $value){
>         if(!$this->personaTableJoined){
>             $rootAlias = $query->getRootAlias();
>
>             $query->innerJoin($rootAlias.'.Persona p');
>             $this->personaTableJoined = true;
>         }
>
>         $quotedValue = $query->getConnection()->getDbh()->quote('%'.
> $value.'%', PDO::PARAM_STR); //escape quotes
>
>         $query->andWhere('p.'.$field.' LIKE '.$quotedValue);
>     }
>
> Is there any better solution? I think the autogenerated filter form o
> symfony have the same problem but I'm no sure.
>
> regards

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en


[symfony-users] Escaping quotes in doctrines form filter with text search

2010-09-16 Thread jdeveloper
Hi

I tested to find text witch contained quotes with the symfonys
generated form filters with doctrine and found out that the quotes are
not escaped (I use mysql).

I published a litle gist overriding addTextQuery in
BaseFormFilterDoctrine;

getFieldName($field);

if (is_array($values) && isset($values['is_empty']) &&
$values['is_empty'])
{
  $query->addWhere(sprintf('(%s.%s IS NULL OR %1$s.%2$s = ?)',
$query->getRootAlias(), $fieldName), array(''));
}
else if (is_array($values) && isset($values['text']) && '' !=
$values['text'])
{
  $quotedValue = $query->getConnection()->getDbh()->quote('%'.
$values['text'].'%', PDO::PARAM_STR); //escapes the quotes in the
value, maybe you want to search text witch has quotes

  $query->addWhere(sprintf('%s.%s LIKE %s', $query-
>getRootAlias(), $fieldName,$quotedValue));
}
  }
}
?>

And here the gist url: http://gist.github.com/582779

I hope it can be usefull for someone

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en