public function getAll($table_name, $byColumns) { if (!is_array($byColumns)) { throw new \Exception("\$byColumns must be an associative array of 'column => value' pairs"); } $table = new Table($table_name, true, $this); $equals = []; $params = []; foreach ($byColumns as $field => $value) { $equals[] = $table->quoteIdentifier($field) . ' = ?'; $params[] = $value; } $where_sql = implode(' AND ', $equals); $sql = 'SELECT * FROM ' . $table->quoteIdentifier($table->getName()) . ' WHERE ' . $where_sql; $stmt = $this->_pdo->prepare($sql); $r = $stmt->execute($params); if ($r === false) { $error = $stmt->errorInfo(); Logger::error('SQL statement failed: ' . $sql . ' ERROR MESSAGE: ' . $error[2] . ' ERROR CODE: ' . $error[1]); } $rows = []; while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) { $rows[] = new Row($table_name, $result, $this); } return $rows; }