Redbean Updating Linking Values For Shared Lists -


i have 2 tables linked together: product , attributetype linked through attributetype_product. linking table has data relationship in it. cannot figure out easy way update data in linking table using redbean. setting initial data easy enough using link() function. cannot figure out how change relationship easily. know can use ownattributetype_product update record once i've loaded product bean, requires know id of linking record.

any on how update link, potentially through shared list?

the way have found make work load linked bean iterate on it's sharedattributetypelist until 1 has right primary bean id.

$project = r::dispense( 'project' ); $project->name = 'useless'; $employee = r::dispense( 'employee' ); $employee->name = 'employee'; $project->link('employee_project', [ 'role' => 'director' ])->employee; r::store( $project );  $directors = $project   ->with(' employee_project.role=?', [ 'director' ] )   ->ownemployeelist; $director = reset( $director ); foreach( $director->xownemployeeprojectlist $bean ){   if( $bean->project_id == $project->id )     break; }  //now $bean contains correct employee_project bean , can worked on 

most often, however, slight design , scope changes in how accessing , thinking linking beans made type of access unnecessary. @ why adding qualifications linking bean , try abstract own domain model or limit scope of access allowed require kind of looking through linking beans can know, in example, project id, employee id or other information specify linking bean need , use "with" retrieve necessary linking bean.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -