close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How can i return a boolean from the execute function if it's correct or not

Thread began 9/13/2018 10:28 am by Lucas | Last modified 9/14/2018 3:36 pm by Ray Borduin | 440 views | 5 replies |

Lucas

How can i return a boolean from the execute function if it's correct or not

I need to validate the queries, either with a select, update, delete and insert.
I need you to return me if it was done correctly or not. I am calling from a function and according to what I answer, I must do one or the other action.

Something like this:

if ($stmt->execute()) {
echo 1; // it worked
} else {
echo 0; // it didn't
}


If I do it this way, it always returns 0

Thank you very much!

Sign in to reply to this post

Ray BorduinWebAssist

We would have to update the object to work with something like this. Currently if a select statement errors it writes the error to the page, so you would never get to your echo statement. The execute function doesn't return a result, so it will always be null and therefor always echo 0 to the page when it succeeds and then error in the execute function itself when it fails.

I'm interested in your use case and could update the objects to function in the way you have supposed they would in your code example, but I'd like to understand why it might fail and understand your use case better before going through the effort. Can you provide a little background about what would cause it to fail in the first place and what types of failure you are trying to capture?

Sign in to reply to this post
Did this help? Tips are appreciated...

Lucas

Thank you very much for the quick answer.
For some cases, we need it because we execute some processes that depend on whether others are performed correctly. For example: we perform the user registration, which if the registration form is completed correctly, the function that saves the user in the database is executed, it returns an id and a token, which are sent by mail in an account activation button.
The same happens in the activation URL of the account, when you enter the url, check the database according to the id and token sent, if it is ok, update the user and if you update it correctly, send an email warning that the account is properly activated and redirected to the login.

They are for actions that are performed if other actions are previously completed correctly.

We need this for some particular things like the ones I mentioned earlier. In other parts of the site, we will continue using the query, insert, delete or update as they are done today with the plugin.

Thank you again

Sign in to reply to this post

Ray BorduinWebAssist

Can you do a screen sharing session to work on one of your pages together? I'll help you make the changes in the code necessary to get this working.

Sign in to reply to this post
Did this help? Tips are appreciated...

Lucas

Where do we do it?

Sign in to reply to this post

Ray BorduinWebAssist

I've messaged you via Skype. Please contact me there and we can coordinate a meeting.

Sign in to reply to this post
Did this help? Tips are appreciated...

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...