src/Entities.php
public static function getQueryString($moduleName, array $params, array $select = [ ], $limit = 0, $offset = 0)
    {
        $criteria = array();
        $select = (empty($select)) ? '*' : implode(',', $select);
        $query = sprintf("SELECT %s FROM $moduleName", $select);
        
        if (!empty($params)) {
            foreach ($params as $param => $value) {
                $criteria[ ] = "{$param} LIKE '{$value}'";
            }

            $query .= sprintf(' WHERE %s', implode(" AND ", $criteria));
        }

        if (intval($limit) > 0) {
            $query .= (intval($offset) > 0)
                ? sprintf(" LIMIT %s, %s", intval($offset), intval($limit))
                : sprintf(" LIMIT %s", intval($limit));
        }

        return $query;
    }
public static function getQueryString($moduleName, array $params, array $select = [ ], $limit = 0, $offset = 0)
    {
        $criteria = array();
        $select = (empty($select)) ? '*' : implode(',', $select);
        $query = sprintf("SELECT %s FROM $moduleName", $select);
        
        if (!empty($params)) {
            foreach ($params as $param => $value) {
                $criteria[ ] = "{$param} LIKE '{$value}'";
            }

            $query .= sprintf(' WHERE %s', implode(" AND ", $criteria));
        }

        if (intval($limit) > 0) {
            $query .= (intval($offset) > 0)
                ? sprintf(" LIMIT %s, %s", intval($offset), intval($limit))
                : sprintf(" LIMIT %s", intval($limit));
        }

        return $query;
    }
public static function getQueryString ( $ moduleName , array $ params , array $ select = [ ] , $ limit = 0 , $ offset = 0 ) { $ criteria = array ( ) ; $ select = ( empty ( $ select ) ) ? '*' : implode ( ',' , $ select ) ; $ query = sprintf ( "SELECT %s FROM $moduleName" , $ select ) ; if ( ! empty ( $ params ) ) { foreach ( $ params as $ param => $ value ) { $ criteria [ ] = "{$param} LIKE '{$value}'" ; } $ query .= sprintf ( ' WHERE %s' , implode ( " AND " , $ criteria ) ) ; } if ( intval ( $ limit ) > 0 ) { $ query .= ( intval ( $ offset ) > 0 ) ? sprintf ( " LIMIT %s, %s" , intval ( $ offset ) , intval ( $ limit ) ) : sprintf ( " LIMIT %s" , intval ( $ limit ) ) ; } return $ query ; }
Builds the query using the supplied parameters
@access public
@static
@param  string   $moduleName  The name of the module / entity type
@param  array    $params  Data used to find matching entries
@return string   $select  The list of fields to select (defaults to SQL-like '*' - all the fields)
@return integer  $limit   Limit the list of entries to N records (acts like LIMIT in SQL)
@return integer  $offset  Integer values to specify the offset of the query
@return string   The query build out of the supplied parameters
Builds the query using the supplied parameters