App\services\Database::select PHP Method

select() public method

Select records from table
public select ( string $key, string $value, array $condition = null, string $table = null, boolean $dont_fetch_array = false ) : array | resources
$key string
$value string
$condition array See function `where`
$table string Which table to operate
$dont_fetch_array boolean Return resources if true
return array | resources
    public function select($key, $value, $condition = null, $table = null, $dont_fetch_array = false)
    {
        $table = $table ?: $this->tableName;
        if (isset($condition['where'])) {
            $sql = "SELECT * FROM {$table}" . $this->where($condition);
        } else {
            $sql = "SELECT * FROM {$table} WHERE {$key}='{$value}'";
        }
        if ($dont_fetch_array) {
            return $this->query($sql);
        } else {
            return $this->fetchArray($sql);
        }
    }