src/SweetORM/Database/QueryGenerator.php
public function generateWhere($conditions, &$where, &$values, &$types)
    {
        $where = "";

        // When empty where, no conditions, return and set where empty.
        if (count($conditions) == 0) {
            return;
        }

        $idx = 0;
        $max = count($conditions);

        foreach ($conditions as $criteria) {
            $column = $criteria['column'];
            $operator = $criteria['operator'];
            $value = $criteria['value'];

            // Prepare where clause
            $where .= "$column ";

            // Check our operator
            if ($operator === "IN") {
                // Prepare and loop
                $where .= "IN (";

                $subIdx = 0;
                $subMax = count($value);
                foreach ($value as $subValue) {

                    $where .= "?";
                    $values[] = $this->prepareData($subValue);
                    $types[] = $this->determinateType($subValue);

                    if (($subIdx+1) < $subMax) {
                        $where .= ",";
                    }
                    $subIdx++;
                }
                $where .= ")";
            } else {
                // Will add a normal operator
                $where .= "$operator ";

                $where .= "?";
                $values[] = $this->prepareData($value);
                $types[] = $this->determinateType($value);
            }

            // Adding AND if not last
            if (($idx + 1) < $max) {
                $where .= " AND ";
            }
            $idx++;
        }
    }
public function generateWhere($conditions, &$where, &$values, &$types)
    {
        $where = "";

        // When empty where, no conditions, return and set where empty.
        if (count($conditions) == 0) {
            return;
        }

        $idx = 0;
        $max = count($conditions);

        foreach ($conditions as $criteria) {
            $column = $criteria['column'];
            $operator = $criteria['operator'];
            $value = $criteria['value'];

            // Prepare where clause
            $where .= "$column ";

            // Check our operator
            if ($operator === "IN") {
                // Prepare and loop
                $where .= "IN (";

                $subIdx = 0;
                $subMax = count($value);
                foreach ($value as $subValue) {

                    $where .= "?";
                    $values[] = $this->prepareData($subValue);
                    $types[] = $this->determinateType($subValue);

                    if (($subIdx+1) < $subMax) {
                        $where .= ",";
                    }
                    $subIdx++;
                }
                $where .= ")";
            } else {
                // Will add a normal operator
                $where .= "$operator ";

                $where .= "?";
                $values[] = $this->prepareData($value);
                $types[] = $this->determinateType($value);
            }

            // Adding AND if not last
            if (($idx + 1) < $max) {
                $where .= " AND ";
            }
            $idx++;
        }
    }
public function generateWhere ( $ conditions , & $ where , & $ values , & $ types ) { $ where = "" ; // When empty where, no conditions, return and set where empty. if ( count ( $ conditions ) == 0 ) { return ; } $ idx = 0 ; $ max = count ( $ conditions ) ; foreach ( $ conditions as $ criteria ) { $ column = $ criteria [ 'column' ] ; $ operator = $ criteria [ 'operator' ] ; $ value = $ criteria [ 'value' ] ; // Prepare where clause $ where .= "$column " ; // Check our operator if ( $ operator === "IN" ) { // Prepare and loop $ where .= "IN (" ; $ subIdx = 0 ; $ subMax = count ( $ value ) ; foreach ( $ value as $ subValue ) { $ where .= "?" ; $ values [ ] = $ this -> prepareData ( $ subValue ) ; $ types [ ] = $ this -> determinateType ( $ subValue ) ; if ( ( $ subIdx + 1 ) < $ subMax ) { $ where .= "," ; } $ subIdx ++ ; } $ where .= ")" ; } else { // Will add a normal operator $ where .= "$operator " ; $ where .= "?" ; $ values [ ] = $ this -> prepareData ( $ value ) ; $ types [ ] = $ this -> determinateType ( $ value ) ; } // Adding AND if not last if ( ( $ idx + 1 ) < $ max ) { $ where .= " AND " ; } $ idx ++ ; } }
Generate Where clause

@param array $conditions
@param string $where Reference of where string
@param array $values Reference of binding values to append
@param array $types Reference of binding value types to append
Generate Where clause