2010-08-09 4 views
0

내가 오류가 점점 오전 예상대로 작동하지 않습니다와 절 :
메시지 :어디 Zend_Db가

$select = $this->_db->select('') 
      ->from(array('t'=>'as_text')) 
      ->where('`s`.`name` LIKE %?%',$search) //this is causing error 
      ->limit((int)$limit) 
      ->order('text_id DESC') 
      ->join(array('s'=>'as_source'),'t.source_id = s.source_id',array('s.name as source')); 

내 목표는이 SQL이 코드 행으로 인한 DESC LIMIT 10' at line 2

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%'Chinese'%) ORDER BY text_id :

SELECT `t` . * , `s`.`name` AS `source` 
FROM `as_text` AS `t` 
INNER JOIN `as_source` AS `s` ON t.source_id = s.source_id 
WHERE `s`.`name` LIKE '%Chinese%' 
ORDER BY `text_id` DESC 
LIMIT 10 

내가 생각하기에 그것은> 암탉 내가 10 행을 제거합니다.

답변

1

편집 : 이것은 나를 위해 작동 :

 ->from(array('t'=>'as_text')) 
     ->where("s.name LIKE ?",'%'.$search.'%') //this is causing error 
     ->limit((int)$limit) 
     ->order('text_id DESC') 
     ->join(array('s'=>'as_source'), 
     't.source_id = s.source_id', 
     array('s.name as source')); 

가 작동하는지 알려주세요.

+0

아니,하지만 그 후에도 여전히 'SQLSTATE [42000] : 구문 오류 또는 액세스 위반 : 1064 오류가 발생합니다. SQL 구문에 오류가 있습니다. '%'중국어 '% 근처에서 사용할 올바른 구문에 대한 MySQL 서버 버전에 해당하는 설명서를 확인하십시오. ORDER BY'text_id' DESC LIMIT 10'on 2 ' – Moak

+0

시도해 보았습니다. 그런 식으로 funtional 쿼리를 생성합니다. . 문제는 WHERE 절이 다음과 같이 끝나야한다는 것입니다. WHERE s.name LIKE '% blah %' – user387302