Why don't you use just a simple string to build your SQL statement and then
use the exec() function to run it. Why have the overhead of building the
SQL when you already have the string?

Similar to this:

```php

    public function getSelectJSON($start = 0, $limit = 100, $direction =
"ASC") {
        $sql = "SELECT geoLang_id,";
        $sql .= " geoLang_name,";
        $sql .= " geoLang_roman,";
        $sql .= " geoLang_isRTL,";
        $sql .= " geoLang_ISO639";
        $sql .= " FROM geoLang ";
        $sql .= " WHERE geoLang_isVisible = 1 ";
        $sql .= " ORDER BY geoLang_roman $direction ";
        $sql .= " LIMIT $start,$limit ;";

        $statement = $this->tableGateway->getAdapter()->query($sql);
        $dataSrc = $statement->execute();
        return $dataSrc;
    }

```




Richie Bartlett Jr (バートレット理路)


On Fri, Feb 14, 2014 at 4:58 PM, doli <d...@yudiz.com> wrote:

> My Query is like:
>
> SELECT tbl_leads . * , tbl_lead_category.vLeadCategoryName AS
> vLeadCategoryName, tbl_lead_category.vLeadCategoryIcon AS
> vLeadCategoryIcon,
> Concat( vFirst, ' ', vLast ) AS vFirst
> FROM tbl_leads
> LEFT JOIN tbl_lead_category ON tbl_lead_category.iLeadCategoryID =
> tbl_leads.iLeadCategoryID
> LEFT JOIN tbl_user ON tbl_user.iUserID = tbl_leads.iUserID
> WHERE (
> tbl_leads.eDeleted = '0'
> )
> AND (
> tbl_leads.iUserID = '1'
> )
> AND (
> vCompanyName LIKE '%t%'
> OR vCompanyUrl LIKE '%t%'
> OR vPersonName LIKE '%t%'
> OR vDesignationName LIKE '%t%'
> OR vSkypeID LIKE '%t%'
> OR vEmailID LIKE '%t%'
> OR vPhoneNumber LIKE '%t%')
>
>
> and my code for this:
>
>
> $select = $this->tableGateway->getSql()->select();
>         $select->columns(array('*'));
>         $select->join('tbl_lead_category',
> 'tbl_lead_category.iLeadCategoryID = tbl_leads.iLeadCategoryID',
> array('vLeadCategoryName', 'vLeadCategoryIcon'), "LEFT")
>                 ->join('tbl_user', 'tbl_user.iUserID  =
> tbl_leads.iUserID',array("vFirst"=>new
> \Zend\Db\Sql\Predicate\Expression("Concat(vFirst,' ',vLast)")),"LEFT");
>         //$select->join('tbl_designation', 'tbl_designation.iDesignationID
> =
> tbl_leads.iDesignationID', array('vDesignationName'), "LEFT");
>
>         $where = new \Zend\Db\Sql\Where();
>         $where->NEST->equalTo('tbl_leads.eDeleted','0')->UNNEST;
>
>
>         if(isset($iUserID) && $iUserID != "")
>             $where->AND->NEST->equalTo ('tbl_leads.iUserID',
> $iUserID)->UNNEST;
>
>         // start for searching
>         if (isset($data['sSearch']) && $data['sSearch'] != "") {
>             for ($i = 0; $i < count($aColumns) - 1; $i++) {
>                     $where->OR->like($aColumns[$i], "%" . $data['sSearch']
> .
> "%");
>                 // how can i get  parentheses to my where which i am
> searching
>             }
>         }
>
>         /*i have tried this, but its giving error: not nested**/
>         if (isset($data['sSearch']) && $data['sSearch'] != "") {
>                 $where->AND->NEST;
>             for ($i = 0; $i < count($aColumns) - 1; $i++) {
>                     $where->OR->like($aColumns[$i], "%" . $data['sSearch']
> .
> "%");
>                 // how can i get  parentheses to my where which i am
> searching
>             }
>                 $where->UNNEST;
>         }
>
>
>
> pls suggest me for solution.
>
>
>
>
> --
> List: fw-general@lists.zend.com
> Info: http://framework.zend.com/archives
> Unsubscribe: fw-general-unsubscr...@lists.zend.com
>
>
>

Reply via email to