Basecoat\DB::fetchField PHP Method

fetchField() public method

Fetch a single field from a select query. Use for when you just want a list of values, like IDs, for processing.
public fetchField ( string $fieldName, boolean $useMaster = false ) : array
$fieldName string field name to get
$useMaster boolean set to TRUE to use the master server connection
return array list of values fetched
    public function fetchField($fieldName, $useMaster = false)
    {
        if ($useMaster) {
            $sth =& self::$msth;
        } else {
            $sth =& $this->sth;
        }
        if (!is_object($sth)) {
            $this->errorCode = 'n/a';
            $this->errorMsg = 'Statement handle is not an object.';
            return -1;
        }
        while ($row = $sth->fetch(\PDO::FETCH_ASSOC)) {
            $this->selectResult[] = $row[$fieldName];
        }
        return $this->selectResult;
    }