мы используем базу данных Zend Frame и доктрину.
Теперь моя проблема в том, что я хочу найти строку (например: testin'g) строку с "одинарными кавычками".
Запрос Doctrine не может извлечь данные для запроса с объединениями и работает нормально с обычным запросом без объединений.
мой метод
public function getNewsListGrid($campid,$currentPage,$resultsPerPage,$quickSearchType,$queryv,$sortName,$sortOrder,$letterPressed)
{
$query = new Doctrine_Query();
$whereCond ='';
$where='eng.id='.$campid;
$select='';
$search = '';
if($letterPressed == 'All')
{
$where .="";
}
else if($letterPressed == 'Radian6')
{
$where .=" AND c.news_type = 1";
}
else if($letterPressed == 'Google News')
{
$where .=" AND c.news_type = 3";
}
else if($letterPressed == 'Google Blogs')
{
$where .=" AND c.news_type = 4";
}
else if($letterPressed == 'Hide Twitter')
{
$where .=" AND c.url NOT LIKE '%twitter.com%'";
}
else if($letterPressed == 'Hide Facebook')
{
$where .=" AND c.url NOT LIKE '%facebook.com%'";
}
else if($letterPressed == 'Hide Facebook-twitter')
{
$where .=" AND c.url NOT LIKE '%twitter.com%' AND c.url NOT LIKE '%facebook.com%'";
}
else if($letterPressed == 'Show Twitter')
{
$where .=" AND c.url LIKE '%twitter.com%'";
}
else if($letterPressed == 'Show Facebook')
{
$where .=" AND c.url LIKE '%facebook.com%'";
}
else if($letterPressed == 'show Facebook-twitter')
{
$where .=" AND c.url LIKE '%twitter.com%' OR c.url LIKE '%facebook.com%'";
}
if($queryv!='' && (trim($letterPressed) != 'Law' && trim($letterPressed) != 'Ls Translate')){
$search = ' c.title like "%'.mysql_real_escape_string($queryv).'%" ';
}
$select='c.id, c.campaign_id, c.title as title, c.domain, c.news_type,c.url, c.active, c.article_date, c.created_date, c.modified_date, t.language_id, t.tr_translated_date, t.tr_translated_by, t.translation_state, t.tr_title, t.raw_title';
if(trim($letterPressed) == 'Original')
{
$select='c.id, c.campaign_id, c.title as title, c.domain, c.news_type,c.url, c.active, c.article_date, c.created_date, c.modified_date, t.language_id, t.tr_translated_date, t.tr_translated_by, t.translation_state';
}
if(trim($letterPressed) == 'Law')
{
$select='c.id, c.campaign_id, c.domain, c.news_type,c.url, c.active,c.article_date, c.created_date, c.modified_date, t.raw_title as title, t.language_id, t.tr_translated_date, t.tr_translated_by, t.translation_state';
if($queryv!='')
$search = ' t.raw_title like "%'.mysql_real_escape_string($queryv).'%" ';
}
if(trim($letterPressed) == 'Ls Translate')
{
$select='c.id, c.campaign_id, c.domain, c.news_type,c.url, c.active, c.article_date, c.created_date, c.modified_date, t.tr_title as title, t.language_id, t.tr_translated_date, t.tr_translated_by, t.translation_state';
$where .=" AND t.translation_state = 1";
if($queryv!='')
$search = ' t.tr_title like "%'.mysql_real_escape_string($queryv).'%" ';
}
$whereCond.=$where;
$query->select($select)
->from('News c')
->leftJoin('c.TranslatedNews t')
->leftJoin('c.Campaigns eng')
->where($whereCond)
->addWhere('eng.tr_language_id=t.language_id')
->orderBy('c.'.$sortName. ' ' . $sortOrder)
->groupBy('c.title')
->addGroupBy('c.url');
if(!empty($search))
$query->addWhere($search);
//echo $query->getSqlQuery();exit;
/*
here when i output query and run in any query browser it works fine.
*/
$pager = new Doctrine_Pager($query,$currentPage, $resultsPerPage);// here it fails to retrive data
return $pager;//print_r($pager);exit;