I have a php script lets say during execution the scripts throws an exception. I want my PHP to resume from where it left off (where it had thrown the exception).
Sh
I am going to assume that you are unable to handle the exception in the function it is being thrown. If you want to resume where your exception was thrown you need to handle the exception there. Anything else is bad coding resulting in confusion for you or anyone else working on the project. We let exception go up the tree because we can't handle them in the function it self because of scope issues.
As to your example which I will expand upon. You say operation can't continue because connection cannot happen. In reality we don't want to blatantly retry the function because we will essentially create a hang point of continuously trying the connection so we use a catch block higher up the tree where we can notify the user and have them decide what we want to do. In so doing we can use catch blocks in the right places to save data so we can restore the data and execute it at a later time. In reality we want to wind-up at a point before the try block.
This will give you a much clearer execution path. Sometimes you have to rethink a function/method so that it does one thing and one thing correctly.
To put the answer to your question simply and bluntly. No, Its a bad idea to call the try(ed) function in the catch block and the simple reason is this you no long have a try block to catch an exception there. Exceptions bring more meaningful error handling then just passing true and false as a return. However, it does mean that you have to go around the full circle in handling them.
Now for an alternate example... Say we have multiple servers that we can connect to and you wanted to run thought the list you would put the try/catch inside a loop and the catch will check for that exception and do any clean up before executing the next loop. If any other exception occurs we will (re)throw the exception. The right way to achieve what your looking for would be like this.
function someCode() {
$pdostmt = $this->prepare($this->sql);
while($status == false) {
try {
$status = $pdostmt->execute($this->bind)
} catch (PDOException $e) {
if($e->getMessage("What ever the error message is") {
//Fix it here
} else {
throw $e;
}
}
}
//Do other stuff
return $data; //or true/false
}