Apply for Zend Framework Certification Training

Zend Framework 2




In Model file 

    you need to include
       $sql = $this->tableGateway->getSql();
   and to print the query 
       echo $sql->getSqlstringForSqlObject($sqlSelect); die ;
    
<?php
namespace Application\Model;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql\Where;
class HotelTable
{
	protected $tableGateway;
	public function __construct(TableGateway $tableGateway)
	{
		$this->tableGateway=$tableGateway;
	}
	
	public function fetchAll()
	{
		$sql = $this->tableGateway->getSql();
		$sqlSelect = $this->tableGateway->getSql()->select();
		$sqlSelect->columns(array('*'));
		$sqlSelect->join('employee', 'employee.id = hotel.hotelId', array(), 'inner');
		echo $sql->getSqlstringForSqlObject($sqlSelect); die ;
		$resultSet= $this->tableGateway->selectWith($sqlSelect);
		return $resultSet;
		
	}
}                                    

< Login And Logout in Zend Framework 2 Last >



Ask a question



  • Question:
    {{questionlistdata.blog_question_description}}
    • Answer:
      {{answer.blog_answer_description  }}
    Replay to Question


Back to Top