I am trying to use a php class for pagination of db query results.
The class constructor requires a db connection to be passed in.
class pagination {
var $conn = false;
...
function pagination($connection, $sql, $rows) {
$this->conn = $connection;
...
}
...
}
I would like to use the existing db connection that already persists in my instance of modx.
I was thinking either:
1. alter the class so that I somehow use "global $modx;" from inside it (as I do in all my snippets). Or,
2. just get the connection from the current $modx and pass that into the constructor.
Can anyone tell me how I should be doing this?