Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7749853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:08:26+00:00 2026-06-01T11:08:26+00:00

In my college days I remember a php code that handles errors like this..

  • 0

In my college days I remember a php code that handles errors like this..

$rs = $mymodel->find("usr=:usr",array("usr"=>"mahan")) on error echo $mymodel->geterror();

but i know the code above is wrong…

It’s an error handling code I could not remember anymore..

maybe you would suggest something like this

/**First code suggestion**/
    if(!mymodel->find("usr=:usr",array("usr"=>"mahan"))){
        $rs = mymodel->find("usr=:usr",array(":usr"=>"mahan"));
    }

or like this

/**Second code suggestion**/
    try{
       $rs = mymodel->find("usr=:usr",array("usr"=>"mahan"));
    }
    catch(Exception $e){
      dump($e);
    }

My problem is I don’t want to repeat the same operation just to test it if it will have errors(shown on the first code suggestion).

And the second code suggestion doesn’t work.

the error handling I shown on very foremost of my question is wrong but I think it would solve my problem(I just don’t remember the right one)… if not tell me your suggestions.

I’m using Yii Framework

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:08:27+00:00Added an answer on June 1, 2026 at 11:08 am

    Don’t understand where you hit the road block because you can still assign to a variable:

    if (! $rs = $mymodel->find("usr=:usr",array("usr"=>"mahan")))
    {
       # failed.
    }
    

    So there is no need to execute the same function again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question brings me back to my college days, but since I haven't coded
I'm doing my college's task. I wrote like this int debut[10][100]; char ngroup[10][100]; do
I'm a college student doing a Java homework. I've created this program that allows
I cant remember from my days in college, the way to compare two unsorted
I happened to debate with a friend during college days whether advanced mathematics is
In college I've had numerous design and UML oriented courses, and I recognize that
I've learned in College that you always have to free your unused Objects but
I am a college student at a school that teaches mainly in Java. One
I work at a college that uses an intranet based student management solution not
Back in college, only the use of pseudo code was evangelized more than OOP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.