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 7894323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:21:59+00:00 2026-06-03T07:21:59+00:00

Given example: table->person – table->books(uses->person_id) – table->notebook(uses->person_id) In my Zend classes i define all

  • 0

Given example: “table->person” – “table->books”(uses->person_id) – “table->notebook”(uses->person_id)

In my Zend classes i define all relations from person to books and notebook and reverse. Now obviously if i want to delete that person, my application should make sure that this person no longer is in possession of anything (at least that’s what i want to achieve).

Obviously with a small example i could check easily if $person->hasBooks() || $person->hasNotebooks() but as the database grows theres shoes and pants and glasses and lots of small stuff.

Is there ANY want to automate it in a way like

foreach ( connectedGoods in person as theGood) 
{
  if ( person->hasGood( theGood ) ) {
    //log person still uses theGood
  } 
} 

Or do i at all times have to manually check each “connectedGood”?

To Clarify: i do know how i can findDepentendRowset('singleTable') – i just wanna know if there’s like a findDepentendRowset('allDependentTables')

Thanks in advance

//Edit
Here is my current table structure to give a little more insight:

tbl_buildings:
b_id
b_*

tbl_asset_x
a_id
b_id (tbl_buildings)

tbl_asset_y
y_id
b_id (tbl_buildings)
  • 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-03T07:22:01+00:00Added an answer on June 3, 2026 at 7:22 am

    If I understand you correctly, this should achieve your goals. I’ve added a method to the table row which checks each of its dependents.

    abstract class MyBaseTable extends Zend_Db_Table_Abstract {
        protected $_rowClass = 'MyBaseTableRow';
        public function getReferences() {
            return $this->_referenceMap;
        }
    }
    
    abstract class MyBaseTableRow extends Zend_Db_Table_Abstract {
        public function hasDependents() {
            foreach ($this->_getTable()->getReferences() as $entity => $info) {
                if (count($this->findDependentRowset($entity) > 0) {
                    return true;
                }
            }
            return false;
        }
    }
    
    class Persons extends MyBaseTable {
        protected $_referenceMap    = array(
            'Book' => array(
                'columns'           => 'reported_by',
                'refTableClass'     => 'Books',
                'refColumns'        => 'account_name'
            ),
            'Notebook' => array(
                'columns'           => 'assigned_to',
                'refTableClass'     => 'Notebooks',
                'refColumns'        => 'account_name'
            )
        );
    }
    
    $persons = new Persons();
    $person = $persons->find(1234);
    
    if ($person->hasDependents()) {
        echo 'freaking remove assets first';    
    } else {
        $person->delete();
    }
    

    Note: Untested!

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

Sidebar

Related Questions

Given an example html string <table> <tr> <td class=td height=25>Upstream Power</td> <td class=td>25.2 dBmV</td>
Given the example table below, how can I retrieve the high and low range
Given a database table example: ID Name DateOfBirth Say I wanted to create an
How can I return a list of fields from a given table that contain
Please give me code example to insert records containing SQL statement: insert into TABLE
Please give me some examples of jump table usage. I have seen this example
When using downloaded R packages, such as tm, the given example usually loads an
I'm trying to solve this problem : http://uva.onlinejudge.org/external/7/732.html . For the given example, they
Given below example, I want to figure out what causes the exception of NameError:
Given the example source code below, is it possible for someone to see the

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.