/** * Runs an execute and fetch query to the database. * * @param PDOStatment $STH prepared PDO statement * @param array [$bindParams = null] parameters to bind to the exeucute statement * * @return array of fetched data */ private static function fetch($STH, $bindParams = null) { //Check to see ff binding parameters needed, add if needed $bindParams === null ? $STH->execute() : $STH->execute($bindParams); //Create empty array to place result $result = array(); //Loop through and place each row into result array while ($row = $STH->fetch()) { $result[] = $row; } //Return result return $result; }