'while(doSome())' can i do this?
<p>So...</p>

<pre><code>class postQuery {

public function __construct($args = NULL){

    $post_type = $args['post_type'];
    $limit = $args['limit'];
    $category = $args['cat'];

    global $sql;

    $sql = $sql-&gt;query('SELECT * FROM posts');
    $sql = $sql-&gt;fetchAll(PDO::FETCH_ASSOC);
}

public function havePosts() {

    global $sql;
    global $rowNum;

    $rowNum = 0;
    $rowMax = count($sql);

    while($rowNum &lt;= $rowMax) {
        return $rowNum;
        $rowNum++;
    }

}
}
</code></pre>

<p>the havePosts() function should run while $rowNum &lt; $rowMax... everything ok this far...</p>

<p>but now, i want to create a while statement with this function, like this:</p>

<pre><code>$con = new postQuery();

while($con-&gt;havePosts()){
    global $sql;
    global $rowNum;

    return $sql[$rowNum]['title'];
}
</code></pre>

<p>How can i return the data given by my WHILE inside the Function one by one?</p>
