⚠ 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

callback_before_insert and set_relation_n_n functions



elanouar
  • profile picture
  • Member

Posted 04 July 2013 - 16:13 PM

Hi,
Before saving all information in the db I would like to get all information that figure into the ‘affectation’ field(generated by set_relation_n_n function).

I tried to use the callback_before_insert function but I have not found the right method to extract information from the array that figure into the callback function that would be called.

 I would appreciate it if you could help me!!


davidoster
  • profile picture
  • Member

Posted 04 July 2013 - 20:10 PM

Within the callback_before_insert function use the $post_array['affectation']. I believe this will return either a comma delimited string

e.g. 1234,5678 or

an array('1234' => 'aaaaa', '5678' => 'test')


elanouar
  • profile picture
  • Member

Posted 05 July 2013 - 22:09 PM

hi davidoster,

tks for your response . I made a call to a callback_before_insert function and for testing I inserted the code below but I do not think that is functional :

function checking_and_sending($post_array)
    {  
	    $z=$post_array['Affectation']; 
		$count = count($z);
		for ($i = 0; $i < $count; $i++) {
     
       echo "Test : ".$z['$i'] . "\n";
    
   }
		

davidoster
  • profile picture
  • Member

Posted 05 July 2013 - 23:15 PM

Instead of echo do a print_r to tell exactly what's the type and content.

Also make sure the case is correct on 'Affectation'. It could be 'affectation' instead.


elanouar
  • profile picture
  • Member

Posted 07 July 2013 - 15:37 PM

Hi davidoster ,

I tried to use the print_r and even the var_dump function. Unfortunately I'm unable to extract data from the selected fields of the list.
Is there any other alternative  that could resolve the pb?
Tks in advance.


davidoster
  • profile picture
  • Member

Posted 09 July 2013 - 08:54 AM

Share your code along with the structure of the table(s).