⚠ 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

set_relation with value field for WHERE



eric
  • profile picture
  • Member

Posted 22 November 2013 - 19:46 PM

Hi.
Can i get current value of field  for un parameter of set_relation .

I have this table :

CREATE TABLE personne(
  numpersonne serial NOT NULL,
  nom character varying(20) NOT NULL,
  prenom character(20) NOT NULL,
  datenaissance date,
  codepostalpers bigint NOT NULL,
  ----------
  refcommune integer,
  ----------
  ...

 
  refcommune is a foreign key and i use set_relation to the table commune :
 

 CREATE TABLE commune(
  numcommune serial NOT NULL,
  commune character varying(50) NOT NULL,
  codepostal character(5) NOT NULL,
  CONSTRAINT pk_commune PRIMARY KEY (numcommune )
)

  

my code

 $crud->set_theme('datatables');
    $crud->set_table('personne');    
    $crud->fields('nom','prenom','datenaissance','codepostalpers','refcommune');
    
    $crud->set_relation('refcommune','commune','{codepostal} - {commune}', array('codepostal' => XXXXXXXXXXX) );

 
  In set_relation with the 4° parameter : With the constant '31000' for codepostalpers  it's Ok
  I have the rows of commune with '31000'
 

$crud->set_relation('refcommune','commune','{codepostal} - {commune}', array('codepostal' => '31000') );

but i want to use the current value of codepostalpers of my table personne
 

$crud->set_relation('refcommune','commune','{codepostal} - {commune}', array('codepostal' => XXXXXXXXXXXXXXX) );


How replace XXXXXXXXX  by the field  codepostalpers of my grid ?

THX for help and time.