How to get all the recordset data into $rows

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
stephen21345
User
Posts: 44

How to get all the recordset data into $rows

Post by stephen21345 »

Hi, I wanted to access a global $rows of all the table data from the current sql query for the list page.

I tried something like which did what i expected, but deletes the recordset afterwards so PHPMaker code has no data of the table...

function Recordset_Selected(&$rs)
{
    global $rows;
    $result = $rs->Result; // Get the Doctrine\DBAL\Result Object
    // Fetch all rows as an array of associative arrays
    $rows = $result->fetchAllAssociative();
}

How can I access all the data from the original recordset so i can turn it into a global $rows object or similar to access in Page_Render and Row_Render.

I pretty sure I could grab the SearchWhere in Recordset_Select instead, and just run the same query to the database twice, but I am trying to avoid that.

Thanks


arbei
User
Posts: 9384

Post by arbei »

You cannot use the same resultset because you cannot rewind it. You do need to make another query.


stephen21345
User
Posts: 44

Post by stephen21345 »

So just to clarify, If I want to aggregate the PHPMaker selected data into a global, can I do it somewhere before the first row_rendered is run?


arbei
User
Posts: 9384

Post by arbei »

You still need to execute another query. You may use Recordset_Searching and use the filter passed to the event.


Post Reply