int
pq\Connection::on(string
$event, callable
$callback)Listen for an event.
string
$event#callable
$callback# as function(pq\Connection $c#[, pq\Result $r#)callback
to invoke on event.int
, number of previously attached event listeners.
<?php
$connection = new pq\Connection;
$connection->on(pq\Connection::EVENT_RESULT, function($c, $r) {
printf("Got result with %d rows\n", $r->numRows);
});
$connection->exec("SELECT * FROM generate_series(1,3)");
?>
Yields:
Got result with 3 rows