2014-05-22 5 views
-2

제발 당신의 도움이 필요 해요! 젠드 프레임 워크 1을 사용하여 각 페이지의 기사를 관리하는 응용 프로그램을 만들고 있습니다. 각 페이지마다 기사를 표시하고 싶습니다.검색어 : SELECT`articles`. * FROM`articles` WHERE()

public function getPagearticle(){ 
    $db = Zend_Db_Table::getDefaultAdapter(); 
    $select = new Zend_Db_Select($db); 
    $select = $db->select() 
      ->from(array('a' => 'articles'), array('page_id', 'Nom_article')) 
      ->join(array('p' => 'pages'), 'p.id = a.page_id',array('p.nom')); 
    $resultRows = $this->fetchAll($select); 


    } 

하지만 난이 오류가있어 : SQLSTATE를 [42000] : 구문 오류 또는 액세스 위반 : 1064 당신은 당신의 SQL 구문에 오류가 있습니다; 1 호선에서 ''근처 사용할 수있는 권리 구문에 대한 MySQL 서버 버전에 해당하는 설명서를 확인, 쿼리는 articles를 SELECT * articles 곳에서 ( 는 사실은 내가 당신의 접근 방식을 사용한 적이 나에게

+1

젠드 모른 채 Zend_Db_Table_Abstract {

protected $_name = 'articles'; public function __construct(){ parent::__construct(); } public function getPagearticle(){ $db = Zend_Db_Table::getDefaultAdapter(); $select = new Zend_Db_Select($db); $select = $db->select() ->from(array('a' => 'articles'), array('page_id', 'Nom_article')) ->join(array('p' => 'pages'), 'p.id = a.page_id',array('p.nom')); $resultRows = $this->fetchAll($select); } public function getArticle($id) { $id = (int)$id; $row = $this->fetchRow('id = ' . $id); if (!$row) { throw new Exception("Could not find row $id"); } return $row->toArray(); } public function addArticle($Nom_article, $description,$Img,$date, $Contenue,$is_show) { $data = array( 'Nom_article' => $Nom_article, 'description' => $description, 'Img' => $Img, 'date'=>$date, 'Contenue' => $Contenue, 'is_show'=> $is_show ); $this->insert($data); } public function updateArticle($id,$Nom_article, $description,$Img,$date, $Contenue,$is_show) { $data = array( 'Nom_article' => $Nom_article, 'description' => $description, 'Img' => $Img, 'date'=>$date, 'Contenue' => $Contenue, 'is_show'=> $is_show ); $this->update($data, 'id = '. (int)$id); } public function deleteArticle($id) { $this->delete('id =' . (int)$id); } 

} 확장

클래스 Application_Model_DbTable_Articles Articlemodel의 모든 코드 을 삭제 편집 할 수있는 그 기사를 표시 이 쿼리 빌더는이 쿼리를 작성합니다 (열, 조인 및 홀수 비어 있음). 이것이 올바른 코드일까요? – h2ooooooo

+0

오류 호출 스택이이 메서드로 돌아 가게합니까? 나는 확실히 의심한다! 다시 확인하고 귀하가 얻은 것을 알려주십시오. –

+0

코드는 다음과 같은 쿼리를 생성합니다 :'SELECT a.page_id, a.Nom_article, p.nom 기사로부터 내부 조인 페이지 AS p ON p.id = a.page_id', 원하는 것은 없습니다. 당신은 당신의 질문에 좀 더 정확하게 대답해야합니다. – Volvox

답변

-1

을 도움을 주셔서 감사합니다. 그 상황 인치

내가 뭘에서 사용하는 일반 :: getDefaultAdapter()

"SELECT page_id, nom_article FROM articles join ..." 

같은 단지 일반 텍스트 쿼리는 내가 테이블 개체의 선택을 구축

http://framework.zend.com/manual/1.10/en/zend.db.table.html

시도 대신에 당신의 $ this-> fetchAll ($ 선택)

$resultRows = $db->fetchAll($select); 

사용;을

0

응용 프로그램에서 각 페이지의 페이지 이름을 편집 할 수 있습니다. "편집"을 클릭 그것은, 그게 그 이상한 것 같다