* database object
* @var Database
*/
- protected $database = null;
+ protected $database;
/**
* SQL query parameters
* pdo statement object
* @var \PDOStatement
*/
- protected $pdoStatement = null;
+ protected $pdoStatement;
/**
* SQL query
return $map;
}
+ /**
+ * Returns a one-dimensional list of all rows holding only the value of the specified column. Please see
+ * `fetchAll()` if you simply want to read all rows into an array.
+ *
+ * @param string $column
+ * @return string[]|int[]|float[]
+ */
+ public function fetchList($column) {
+ $list = [];
+
+ while ($row = $this->fetchArray()) {
+ if (!array_key_exists($column, $row)) {
+ throw new \RuntimeException("The requested column '{$column}' is not contained in the result rows.");
+ }
+
+ $list[] = $row[$column];
+ }
+
+ return $list;
+ }
+
/**
* Counts number of affected rows by the last sql statement (INSERT, UPDATE or DELETE).
*