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

  • SEARCH
  • Home
  • 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 6607033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:27:34+00:00 2026-05-25T19:27:34+00:00

I am trying to research the best way to secure users data. Example: An

  • 0

I am trying to research the best way to secure users data.
Example: An application has a table ‘widgets’, each user can have as many ‘widgets’ as required. The application identifies the ‘widgets’ by the ‘userId’ column, which referenced the ID of the logged in user.

Currently the best way I have been able to secure the widget data from being accessed if by overriding the fetchAll() method with my own in my models, and add in WHERE userId = X before passing the params to parent::fetchAll() like so:

class Model_Widgets extends Zend_Db_Table_Abstract {

protected $_name = 'widgets';

/**
 * Abstracted function to ensure data security
 * Adds in a WHERE to the SELECT to check if this user is the datas owner
 * 
 * @see Zend_Db_Table_Abstract::fetchAll()
 */
public function fetchAll($where = null, $order = null, $count = null, $offset = null)
{
    // Handle the additional security check
    $userId = 'userId = ' . Model_Users::getUser()->id;
    // Merge the WHERE userId statement with the rest
    if($where)
    {
        if(is_array($where))
            $where[] = $userId;
        else
            $where = array($where, $userId);
    }
    else
        $where = $userId;

    return parent::fetchAll($where, $order, $count, $offset);
}

This method works fine, but I cant help to think that there must be a better way, I have recently discovered $_rowClass but am still not sure I understand the concept. If overriding concrete functions is the only way to apply these security checks, is there a way to override them once rather than in each model perhaps via a helper, and then simply add a function like the following to each model that needs to check the user against the row:

public function fetchAll(...)
{
    return SecurityCheckHelper::fetchAll(...);

I hope this makes sense, in reality all I am trying to do is make sure users cant access other users data by playing about with ID’s in the URL etc.
Thanks guys

  • 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-05-25T19:27:35+00:00Added an answer on May 25, 2026 at 7:27 pm

    Currently the best way I have been able to secure the widget data from being accessed if by overriding the fetchAll() method with my own in my models, and add in WHERE userId = X before passing the params to parent::fetchAll()

    You really should do this for all functions of Zend_Db_Table_Abstract then as this could result in some nasty bugs later on.

    these security checks, is there a way to override them once rather than in each model perhaps via a helper, and then simply add a function like the following to each model that needs to check the user against the row:

    Why don’t you create a new abstract base class that implements this feature for all of your models? Like My_Db_Table_Abstract extends Zend_Db_Table_Abstract.

    am trying to do is make sure users cant access other users data by playing about with ID’s in the URL etc

    This is the controller’s job!

    In my projects I solve this by using ACL and custom asserts (in my models). This even allows you further modifications without changing your models.

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

Sidebar

Related Questions

I'm trying to do some research on flash objects in browsers. For example memory
I've been trying to figure out the best way to handle local database access
I am trying to understand conceptually the best way to deliver real streaming audio
I am trying to find out the best way for testing admin.ModelAdmin in admin.py
I'm not sure how to best phrase this, especially while trying to research it.
I'm trying to decide on the best way to load in some configuration settings.
I'm trying to do some research to find the best option for sessions management
I am doing a research here to find you the best way to format
I am trying to research available voice recognition engines and SDK for developing a
I am currently trying to research how to use Android with an existing java

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.