public function fieldSelect($table, $fields, $where, $orderBy = null)
    {
        $table = $this->getTableName($table);

        $query = "SELECT ";

        if (substr($this->mode, 0, 5) === "mssql") {
            $query .= "TOP 1 ";
        }

        $query .= $this->selectFields($fields);

        $query .= " FROM " . $table . " ";

        $params = null;
        if ($where !== self::NO_WHERE_CLAUSE) {
            $query .= "WHERE " . $this->where($where, $params);
        }

        if ($orderBy) {
            $query .= $this->orderBy($orderBy) . " ";
        }

        switch ($this->mode) {

            case "mysql":
            case "postgres":
            case "redshift":
            case "sqlite":
                $query .= "LIMIT 1";
                break;

            case "odbc":
                $query .= "FETCH FIRST 1 ROW ONLY";
                break;
        }

        return $this->query($query, $params)->fetch();
    }
public function fieldSelect($table, $fields, $where, $orderBy = null)
    {
        $table = $this->getTableName($table);

        $query = "SELECT ";

        if (substr($this->mode, 0, 5) === "mssql") {
            $query .= "TOP 1 ";
        }

        $query .= $this->selectFields($fields);

        $query .= " FROM " . $table . " ";

        $params = null;
        if ($where !== self::NO_WHERE_CLAUSE) {
            $query .= "WHERE " . $this->where($where, $params);
        }

        if ($orderBy) {
            $query .= $this->orderBy($orderBy) . " ";
        }

        switch ($this->mode) {

            case "mysql":
            case "postgres":
            case "redshift":
            case "sqlite":
                $query .= "LIMIT 1";
                break;

            case "odbc":
                $query .= "FETCH FIRST 1 ROW ONLY";
                break;
        }

        return $this->query($query, $params)->fetch();
    }
public function fieldSelect ( $ table , $ fields , $ where , $ orderBy = null ) { $ table = $ this -> getTableName ( $ table ) ; $ query = "SELECT " ; if ( substr ( $ this -> mode , 0 , 5 ) === "mssql" ) { $ query .= "TOP 1 " ; } $ query .= $ this -> selectFields ( $ fields ) ; $ query .= " FROM " . $ table . " " ; $ params = null ; if ( $ where !== self :: NO_WHERE_CLAUSE ) { $ query .= "WHERE " . $ this -> where ( $ where , $ params ) ; } if ( $ orderBy ) { $ query .= $ this -> orderBy ( $ orderBy ) . " " ; } switch ( $ this -> mode ) { case "mysql" : case "postgres" : case "redshift" : case "sqlite" : $ query .= "LIMIT 1" ; break ; case "odbc" : $ query .= "FETCH FIRST 1 ROW ONLY" ; break ; } return $ this -> query ( $ query , $ params ) -> fetch ( ) ; }
Grab specific fields from the first row from a table using the standard select statement
Grab specific fields from the first row from a table using the standard select statement