See how we can write doctrine query using multiple OR conditions which will prevent you from the special characters.
Example:
$query = Doctrine_Query::create()
->select('u.*, up.*')
->from('sfGuardUser u')
->leftJoin('u.Profile up');
$query->where('u.username LIKE ? OR u.first_name LIKE ? OR u.last_name LIKE ? OR up.fullname LIKE ? OR u.email_address LIKE ? OR up.charity_name LIKE ? OR up.advertiser_name LIKE ? OR up.organization_name LIKE ?',
array('%'.$input.'%', '%'.$input.'%', '%'.$input.'%', '%'.$input.'%', '%'.$input.'%','%'.$input.'%', '%'.$input.'%', '%'.$input.'%'));
->select('u.*, up.*')
->from('sfGuardUser u')
->leftJoin('u.Profile up');
$query->where('u.username LIKE ? OR u.first_name LIKE ? OR u.last_name LIKE ? OR up.fullname LIKE ? OR u.email_address LIKE ? OR up.charity_name LIKE ? OR up.advertiser_name LIKE ? OR up.organization_name LIKE ?',
array('%'.$input.'%', '%'.$input.'%', '%'.$input.'%', '%'.$input.'%', '%'.$input.'%','%'.$input.'%', '%'.$input.'%', '%'.$input.'%'));
No comments:
Post a Comment