db::select PHP Method

select() static public method

Returns multiple rows from a table
static public select ( string $table, mixed $select = '*', mixed $where = null, string $order = null, integer $page = null, integer $limit = null, boolean $fetch = true ) : mixed
$table string The table name
$select mixed Either an array of fields or a MySQL string of fields
$where mixed Either a key/value array as AND connected where clause or a simple MySQL where clause string
$order string Order clause without the order keyword. ie: "added desc"
$page integer a page number
$limit integer a number for rows to return
$fetch boolean true: apply db::fetch(), false: don't apply db::fetch()
return mixed
    static function select($table, $select = '*', $where = null, $order = null, $page = null, $limit = null, $fetch = true)
    {
        if ($limit === 0) {
            return array();
        }
        if (is_array($select)) {
            $select = self::select_clause($select);
        }
        $sql = 'SELECT ' . $select . ' FROM ' . self::prefix($table);
        if (!empty($where)) {
            $sql .= ' WHERE ' . self::where($where);
        }
        if (!empty($order)) {
            $sql .= ' ORDER BY ' . $order;
        }
        if ($page !== null && $limit !== null) {
            $sql .= ' LIMIT ' . $page . ',' . $limit;
        }
        return self::query($sql, $fetch);
    }

Usage Example

Example #1
0
 public function mostrar_usuarios()
 {
     $array = array();
     parent::__construct($this->db, $this->tabla);
     parent::select($array);
     parent::mostrar_resultados();
 }
All Usage Examples Of db::select