⚠ In case you've missed it we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠


Copy a value from another table


  • Please log in to reply
1 reply to this topic

#1 Dan

Dan

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 30 December 2013 - 07:38 PM

Hello, I'm trying to make a callback function for this code.

	public function trips() {
		
		$crud = new grocery_CRUD ();
		
		$crud->set_table ( 'trips' );
		
		$crud->set_relation ( 'driver_id', 'users', 'name', array (
				'user_type' => 'Driver' 
		) );
		
		$crud->set_relation_n_n ( 'passengers', 'users_per_trip', 'users', 'trip_id', 'user_id', 'name', null, "user_type = 'Sub-manager' OR user_type = 'Passenger'" );
		
		
		$crud->add_fields ( 'driver_id', 'date', 'passengers' );
		
		$crud->display_as ( 'driver_id', 'Driver' );
		$crud->display_as ( 'tax', 'Tax' );

        $output = $crud->render ();
        
        $data ['title'] = "Trips";
        
        $this->_example_output ( $output, $data );
    }
   

I have a 'users' table which has a 'price' field and I need to copy that value to my 'users_per_trip' table which has a 'price' field too. What I need here is that when every user is inserted in the 'users_per_trip' table the price is copied where user_id=id from table users, assuming that is a many to many relation. Hope you understand my example.

 

Thank you very much in advance.

 

 

 



#2 GerardoVa

GerardoVa

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 30 December 2013 - 11:22 PM

Nicely put. Thanks!

Here is my web page; Russian Gay (visit the up coming webpage)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users