public function select($columns, $table, $where = '', $replacements = '', $order = '', $limit = '', $cache = false, $calc_rows = false, $highlight = false) {

        // if $columns is not a string, split by comma and trim whitespace
        if (!is_array($columns)) $columns = array_map('trim', explode(',', $columns));

        // iterate over the given columns
        foreach ($columns as $key => $value)

            // and escape everyone except the * character
            if (trim($value) != '*') $columns[$key] = $this->_escape($value);

        // run the query
        return $this->query('

            SELECT
                ' . implode(', ', $columns) . '
            FROM
                ' . $this->_escape($table) .

            ($where != '' ? ' WHERE ' . $where : '') .

            ($order != '' ? ' ORDER BY ' . $order : '') .

            ($limit != '' ? ' LIMIT ' . $limit : '') . '

        ', $replacements, $cache, $calc_rows, $highlight);

    }
public function select($columns, $table, $where = '', $replacements = '', $order = '', $limit = '', $cache = false, $calc_rows = false, $highlight = false) {

        // if $columns is not a string, split by comma and trim whitespace
        if (!is_array($columns)) $columns = array_map('trim', explode(',', $columns));

        // iterate over the given columns
        foreach ($columns as $key => $value)

            // and escape everyone except the * character
            if (trim($value) != '*') $columns[$key] = $this->_escape($value);

        // run the query
        return $this->query('

            SELECT
                ' . implode(', ', $columns) . '
            FROM
                ' . $this->_escape($table) .

            ($where != '' ? ' WHERE ' . $where : '') .

            ($order != '' ? ' ORDER BY ' . $order : '') .

            ($limit != '' ? ' LIMIT ' . $limit : '') . '

        ', $replacements, $cache, $calc_rows, $highlight);

    }
public function select ( $ columns , $ table , $ where = '' , $ replacements = '' , $ order = '' , $ limit = '' , $ cache = false , $ calc_rows = false , $ highlight = false ) { // if $columns is not a string, split by comma and trim whitespace if ( ! is_array ( $ columns ) ) $ columns = array_map ( 'trim' , explode ( ',' , $ columns ) ) ; // iterate over the given columns foreach ( $ columns as $ key => $ value ) // and escape everyone except the * character if ( trim ( $ value ) != '*' ) $ columns [ $ key ] = $ this -> _escape ( $ value ) ; // run the query return $ this -> query ( '

            SELECT
                ' . implode ( ', ' , $ columns ) . '
            FROM
                ' . $ this -> _escape ( $ table ) . ( $ where != '' ? ' WHERE ' . $ where : '' ) . ( $ order != '' ? ' ORDER BY ' . $ order : '' ) . ( $ limit != '' ? ' LIMIT ' . $ limit : '' ) . '

        ' , $ replacements , $ cache , $ calc_rows , $ highlight ) ; }
Shorthand for simple SELECT queries.

For complex queries (using UNION, JOIN, etc) use the {@link query()} method.

When using this method, column names will be enclosed in grave accents " ` " (thus, allowing seamless usage of
reserved words as column names) and values will be automatically {@link escape()}d in order to prevent SQL injections.

<code>
$db->select(
'column1, column2',
'table',
'criteria = ?',
array($criteria)
);

// or

$db->select(
array('column1', 'column2'),
'table',
'criteria = ?',
array($criteria)
);

// or

$db->select(
'*',
'table',
'criteria = ?',
array($criteria)
);
</code>

@param  mixed  $columns         A string with comma separated values or an array representing valid column names
as used in a SELECT statement.

<samp>If given as a string it will be enclosed in grave accents, so make sure you
are only using column names and not things like "tablename.*" or MySQL functions!
Use this argument as an array if you want MySQL functions to be properly skipped
from this process.</samp>

<samp>You may also use "*" instead of column names to select all columns from a
table.</samp>

@param  string  $table          Table in which to search.

<i>May also be given like databasename.tablename if a database was not explicitly
selected with the {@link connect()} or {@link select_database()} methods prior to
calling this method.</i>

<i>Note that table name (and database name, if provided) will be enclosed in grave
accents " ` " and thus only one table name should be used! For anything but a
simple select query use the {@link query()} method.</i>

@param  string  $where          (Optional) A MySQL WHERE clause (without the WHERE keyword).

Default is "" (an empty string).

@param  array   $replacements   (Optional) An array with as many items as the total parameter markers ("?", question
marks) in <i>$where</i>. Each item will be automatically {@link escape()}-ed and
will replace the corresponding "?". Can also include an array as an item, case in
which each value from the array will automatically {@link escape()}-ed and then
concatenated with the other elements from the array - useful when using <i>WHERE
column IN (?)</i> conditions. See second example {@link query here}.

Default is "" (an empty string).

@param  string  $order          (Optional) A MySQL ORDER BY clause (without the ORDER BY keyword).

Default is "" (an empty string).

@param  mixed   $limit          (Optional) A MySQL LIMIT clause (without the LIMIT keyword).

Default is "" (an empty string).

@param  mixed   $cache          (Optional) Instructs the library on whether it should cache the query's results
or not. Can be either FALSE - meaning no caching - or an integer representing the
number of seconds after which the cache will be considered expired and the query
executed again.

The caching method is specified by the value of the {@link caching_method} property.

Default is FALSE.

@param  boolean $calc_rows      (Optional) If this argument is set to TRUE, and there is a LIMIT applied to the
query, the value of the {@link found_rows} property (after the query was run)
will represent the number of records that would have been returned if there was
no LIMIT applied to the query.

This is very useful for creating pagination or computing averages. Also, note
that this information will be available without running an extra query.
{@link http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows Here's how}

Default is FALSE.

@param  boolean $highlight      (Optional) If set to TRUE the debugging console will be opened automatically
and the query will be shown - really useful for quick and easy debugging.

Default is FALSE.

@since  2.0

@return mixed                   On success, returns a resource or an array (if results are taken from the cache)
or FALSE on error.

<i>If query results are taken from cache, the returned result will be a pointer to
the actual results of the query!</i>
Shorthand for simple SELECT queries .