Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to make an object return false by default?
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COOkay, let me clarify a little, because I think in trying to simplify the question, people aren't understanding the heart of it. So here goes: I'm using Zend Framework, which means that I often am using models (for those that don't know they're essentially a quick way to insert/update/whatever with a database). I often call, for example, Users->insertNewUser() in one of my controllers. If it is successful, it returns a Zend_Db_Table_Rowset. However, lets say that username already existed. I don't want to just return false, because that won't tell me what went wrong.
      singulars
    2. COI love this question because it's got a Dog object, Have you tried the Implicit Cast Overloading?
      singulars
    3. COInstead I've created an object called modelResult, that carries with it the reason that the model failed to perform it's function. What I want is to be able to, back in the controller, be able to say $result = Users->insertNewUser(). if($result){return $result} else{ (CHECK WHAT WENT WRONG AND SAY WHY)}. I know I could do this by checking $result's type. I know there are a ton of ways I could do this. But, I was just wondering if I could make my ModelResult object return false because it would just be a lot easier to use. Is there a way to do this? If the answer is no, then I'll manage.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload