Hello,
I would like to update the “count_items” fields for each row in the “categories” table
Can someone help me with the following portion of code? Why can’t I save $rows?
$c = $modx->newQuery( $categoriesTable );
$c->select( $modx->getSelectColumns( $categoriesTable, $categoriesTable ) );
$c->prepare();
if ( $c->stmt->execute() ) {
if ( !$rows = $c->stmt->fetchAll( PDO::FETCH_ASSOC ) ) {
$rows = array();
}
}
foreach ( $rows as $i => $row ) {
$rows[ $i ][ 'count_items' ] = countItems( $i, $modx );
}
$rows->save();
The last line gives:“Fatal error: Uncaught Error: Call to a member function save() on array”
How can I convert $row into a format that I would be able to save?
Thank you for the help