Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

There are no remaining rows

posted by shakeel 8 years ago

I dont wanna no rows found exception . i m using $result->countReturnedRows(); i execute any query and get the number of return rows . if there is no rows in result then it should return only 0 but its always return exception. please tell me how to remove this exception.i dont need this exception . i need only number of rows either zero or whatever in query result.

Shakeel, from what I can tell that method in and of itself does not throw an exception: fResult -- it simply returns the value set to the property, which is set presumably in the creation of the Result object itself, although I didn't confirm this. There are instances where exceptions are thrown such as attempting to fetch a row with fetchRow() if there are none available.

As such, I would presume there might be an error in your logic if indeed you are doing something like the following:

if ($result->countReturnedRows()) {
	// Do some stuff with the rows
}

If you are calling fetchRow without confirming that rows are returned you can wrap it in a try{}/catch(){} block, such as this:

try {
	$result->fetchRow();
	// What to do with the row
} catch (fNoRemainingException $e) {
	// What to do if there are no rows
}

Exceptions are designed to be caught so you can handle them more gracefully without a number of conditionals to handle errors.

posted by mattsah 8 years ago