Select rows from a table

@param string $table
@param mixed $exprs
@param array $where
@param array $orderBy
@param int|null $limitCount
@param int|null $limitOffset
@param array $params
@return \PDOStatement
554275
function select( $table, $options = array() ) {

        $options = array_merge( array(

            'expr' => null,
            'where' => array(),
            'orderBy' => array(),
            'limitCount' => null,
            'limitOffset' => null,
            'params' => array()

        ), $options );

        $query = "SELECT ";

        if ( empty( $options[ 'expr' ] ) ) {

            $query .= "*";

        } else if ( is_array( $options[ 'expr' ] ) ) {

            $query .= implode( ", ", $options[ 'expr' ] );

        } else {

            $query .= $options[ 'expr' ];

        }

        $table = $this->rewriteTable( $table );
        $query .= " FROM " . $this->quoteIdentifier( $table );

        $query .= $this->getSuffix( $options[ 'where' ], $options[ 'orderBy' ], $options[ 'limitCount' ], $options[ 'limitOffset' ] );

        $this->onQuery( $query, $options[ 'params' ] );

        $statement = $this->prepare( $query );
        $statement->setFetchMode( \PDO::FETCH_ASSOC );
        $statement->execute( $options[ 'params' ] );

        return $statement;

    }
151385
private static function smartSelect($table, $fields = null, $where = null) {
        $additional = '';
        if(is_array($table)) {
            $additional = DbCallFunctions::calls($table);
            $table = $table['from'];
        }
        $table = self::sanitizeKey($table);
        $fieldsString = self::handleSelectandi($fields);
        $whereString = !empty($where) ? self::handleConditions($where) : '';
        $whereString .= $additional;
        $sql = 'SELECT ' . $fieldsString . ' FROM ' . self::$_ops->addBackticks($table) . ' ' . $whereString;
        return self::handleResults($sql);
    }
1335135
public function delete($table, $statements, $where)
    {
        $query = 'DELETE FROM `' . $table . '` ';

        $query .= (! is_null($where)) ? ' WHERE ' : '';

        $query .= (is_string($where)) ? $where . ' ' : '';

        if (is_array($where)) {
            foreach ($where as $clause) {
                $query .= $clause . ' AND ';
            }

            $query = rtrim(trim($query), 'AND');
        }

        if (! is_null($statements) && is_array($statements)) {
            return $this->statements($query, $statements);
        }

        return $this->query($query, 'INSERT');
    }
32241
public function find($table, $fields = null, $where = null, $order = null, $limit = null, $offset = null, $array = array(), $fetchMode = \PDO::FETCH_ASSOC)
     {
         $sql = ' SELECT '.(($fields) ?? '*').' FROM '.(($table)).(($where) ? ' WHERE '.$where : ' ')
            .(($limit) ? ' LIMIT '.$limit : ' ')
            .(($offset && $limit) ? ' OFFSET '.$offset : ' ')
            .(($order) ? ' ORDER BY '.$order : ' ');

         $stmt = $this->conn->prepare($sql);

         foreach ($array as $key => $values) {
             return  $stmt->bindValue("$key", $values);
         }
         $stmt->execute();

         do {
             return $stmt->fetchAll($fetchMode);
         } while (
            $stmt->nextRowset());
         $stmt->close();
     }
1328364
public function getOneResult($table, $where = null, $groupBy = null, $orderBy = null)
    {
        return $this->Select($table, $where, $groupBy, $orderBy, 1);
    }
1333109
public function selectArray($fields = null, $where = null, $orderBy = null, $limit = null): array
    {
        return self::select2($fields, $where, $orderBy, $limit);
    }
1294570
public function count(string $table, $where = null, array $whereParams = null, string $op = null): ?int
    {
        $query = $this->prepare('SELECT count(*) AS count FROM %n %v', [$table,
            $this->where($where, $whereParams, $op)]);

        $result = (object) $this->get($query);

        return isset($result->count) ? intval($result->count) : null;
    }
820477
public function select($table = null, $selectFields = array('*'))
    {
    	$this->queryTypeProcess(self::QUERYTYPE_SELECT, $table, $selectFields);
        return $this;
    }
976284
public function delete($where = null, $params = [], $limit = null, $order = null) {

		if(null === $this -> getAdapter()) {
			return trigger_error(sprintf('No database adapter was set in "%s"', __METHOD__), E_USER_ERROR);
		}

		if(null !== $where && false === is_string($where)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($where)), E_USER_ERROR);
		}

		if(false === is_array($params)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($params)), E_USER_ERROR);
		}

		if(null !== $limit && false === is_string($limit)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($limit)), E_USER_ERROR);
		}

		if(null !== $order && false === is_string($order)) {
			return trigger_error(sprintf('Argument 5 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($order)), E_USER_ERROR);
		}

		//Select
		$query[] = sprintf('DELETE FROM %s', $this -> getAdapter() -> escape($this -> getTable()));

		//Where
		if(null !== $where) {
			$query[] = sprintf('WHERE %s', $this -> getAdapter() -> escape($where));
		}

		//Order
		if(null !== $order) {
			$query[] = sprintf('ORDER BY %s', $this -> getAdapter() -> escape($order));			
		}

		//Limit
		if(null !== $limit) {
			$query[] = sprintf('LIMIT %s', $this -> getAdapter() -> escape($limit));
		}

		return $this -> getAdapter() -> query(implode(' ', $query), $params) -> execute();
	}
474243
public function select($table, $cond=null, $fields='*', $sort=null, $limit=null, $calc=false)
	{
		return Sql::assistant( $this->ds )->select($table, $cond, $fields, $sort, $limit, $calc);
	}
1030078
public function select_row($table ,$cond=null ,$fields='*', $sort=null)
    {
    	$ds = $this->ds();
		$cond = SqlHelper::parse_cond($ds,$cond);
		if ($cond) $cond = "WHERE {$cond}";
		if ($sort) $sort = "ORDER BY {$sort}";
		
		$qfields = SqlHelper::qfields($fields,$table);
		
		$result = Sql::read($ds, Sql::MODE_READ_GETROW, [
				"SELECT {$qfields} FROM {$table} {$cond} {$sort}"
			]);
		return $result;
	}
141557
public function delete($table, $where = '')
    {
        $where = $this->_whereExpr($where);

        /**
         * Build the DELETE statement
         */
        $sql = "DELETE FROM "
             . $this->quoteIdentifier($table, true)
             . (($where) ? " WHERE $where" : '');

        /**
         * Execute the statement and return the number of affected rows
         */
        $stmt = $this->query($sql);
        $result = $stmt->rowCount();
        return $result;
    }
309307
public function select($columns = [])
    {
        $expr = new ColumnExpression($this->sql);

        if ($columns instanceof Closure) {
            $columns($expr);
        } else {
            if (!is_array($columns)) {
                $columns = [$columns];
            }
            $expr->columns($columns);
        }
    }
514386
function _select (node, expr) {
        var
            resultSet,
            nodeSet = [node];
        while (expr) {
            resultSet = [];
            _test(nodeSet, expr, resultSet);
            if (0 === resultSet.length) {
                return [];
            }
            nodeSet = resultSet;
            if (expr.filter) {
                resultSet = [];
                _each(nodeSet, _filter, expr.filter, resultSet);
                if (0 === resultSet.length) {
                    return [];
                }
                nodeSet = resultSet;
            }
            expr = expr.then;
        }
        return resultSet;
    }
981
public function count(string $table, $wheres)
    {
        list($where, $bindings) = $this->handleWheres($wheres);
        $sql = "SELECT COUNT(*) AS total FROM {$table} WHERE {$where}";

        $result = $this->fetchObject($sql, $bindings);

        return $result ? (int)$result->total : 0;
    }
294587
public function getRows($table, $columns, $where)
    {
        $columns = implode(',', $columns);
        $sql = "SELECT {$columns} FROM {$table}";

        if ($where) {
            $sql .= " WHERE {$where}";
        }

        $stmt = $this->pdo->query($sql);
        while ($row = $stmt->fetch()) {
            yield $row;
        }
    }
270803
public function select($table, $cond=null, $fields='*', $sort=null, $limit=null, $calc=false)
	{
		$ds = $this->ds();
		$cond = SqlHelper::parse_cond($ds,$cond);
		if ($cond) $cond = "WHERE {$cond}";
		if ($sort) $sort = "ORDER BY {$sort}";
		
		$qfields = SqlHelper::qfields($fields,$table);
		$table = SqlHelper::qtable($table);
		
		$result = Sql::read($ds, Sql::MODE_READ_GETALL, [
				"SELECT {$qfields} FROM {$table} {$cond} {$sort}",
				empty($limit) ? false : $limit,
				$calc
			]);
		return $result;
	}