public static function getMsgBySubject($subjectId) { $result = []; $cursor = \Root\Src\Model\ConnectionModel::getConnection()->query("Select * From mail where subjectId = :subjectId", ["subjectId" => $subjectId]); $i = 0; while ($i < \sizeof($cursor) && $cursor) { $current = new MailModel(); $current->hydrate($cursor[$i]); array_push($result, $current); $i += 1; } return $result; }