/** * select * * composes and executes a select statement * * @param string $select * a select statement to excecute * @param array $filters * a list of filters and filter values * @param string $orderby * a comma separated list of order by fields * @param object $limit * an object having the start and limit fields * * @return array * an array of db objects */ function select($select, $filters = NULL, $orderby = NULL, $limit = NULL) { $viewlimits = is_null($limit) ? '' : ' LIMIT ' . intval($limit->start) . ', ' . intval($limit->limit); $where = is_null($filters) ? '' : EasyContactFormsDB::getWhere($filters); $select = $select . $where; if (!is_null($filters) && isset($filters['fvalues'])) { foreach ($filters['fvalues'] as $key => $value) { $replacement = is_array($value) ? "'" . implode("', '", $value) . "'" : "'" . mysql_real_escape_string($value) . "'"; $select = str_replace($key, $replacement, $select); } } $orderby = is_null($orderby) ? '' : ' ' . $orderby; $select = $select . $orderby . $viewlimits; $select = EasyContactFormsDB::wptn($select); $result = EasyContactFormsDB::getObjects($select); return $result; }