⚠ 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 is an archived forum. ⚠

  •     

profile picture

Copy a value from another table



Dan

Dan
  • profile picture
  • Member

Posted 30 December 2013 - 19: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.

 

 

 


GerardoVa

GerardoVa
  • profile picture
  • Member

Posted 30 December 2013 - 23:22 PM

Nicely put. Thanks! Here is my web page; Russian Gay ([url=http://www.onlycock.com/]visit the up coming webpage[/url])