zend_db and join

Posted by premtemp on Stack Overflow See other posts from Stack Overflow or by premtemp
Published on 2010-04-21T23:45:55Z Indexed on 2010/04/22 0:03 UTC
Read the original article Hit count: 198

Filed under:
|
|

Hello, I am trying to understand how to use Zend_DB in my program but I have some problem. The class below (DatabaseService) work when I pass it a simple query. However, if I pass it it query with a join clause my page just hangs and not error is return. I cut and paste the qry in a query browesr and it is valid

Any help would be great

$SQL = "select name from mytable"

$db = new DatabaseService($dbinfo)

$db ->fetchall($SQL )  // works

-----------------------------------------------------------
$SQL = "select count(*) as cnt from EndPoints join CallID on EndPoints.`CallID` = CallID.CallID where EndPoints.LastRegister >= '2010-04-21 00:00:01' and EndPoints.LastRegister <= '2010-04-21 23:59:59' "

$db = new DatabaseService($dbinfo)

$db ->fetchall($SQL )  // DOES NO WORK

class DatabaseService
{


 function DatabaseService($dbinfo,$dbname="")
 {

  try
  {
  $dbConfig = array( 
      'host'     => $this->host,
    'username' => $this->username,
    'password' => $password,
    'dbname'   => $this->dbname );

                 $this->db = Zend_Db::factory($this->adapter, $dbConfig); 

      Zend_Db_Table::setDefaultAdapter($this->db);
  }
  catch(Zend_Exception $e)
  {
   $this->error = $e->getMessage();
   Helper::log($this->error);
   return false;
  }
 }

 public function connnect()
 {
  if($this->db !=null)
  {
   try

   {
    $this->db->getConnection(); 
       return true; 
   }
   catch (Zend_Exception $e) 
   {   
    $err = "FAILED ::".$e->getMessage()." <br />";


   }
  }
  return false;
 } 

 public function fetchall($sql)
 {

  $res= $this->db->fetchAll($sql);
  return $res;

 }
}

© Stack Overflow or respective owner

Related posts about zend

Related posts about db