* 1 to 1 relationship grocery crud (currently grocerycrud does not have that)
* 1 to n custom column relationship grocerycrud (currenlty need name name)
i now explain how:
1) controller made normal, here tables:
CREATE TABLE tablemain ( colkeymain TEXT, collink_noname TEXT, PRIMARY KEY (colkeymain) ); CREATE TABLE tablerefer ( colkeyrefer TEXT, collink_naming TEXT, PRIMARY KEY (colkeyrefer) );
2) here controller
$arrayrowsfromtablerefer = $this->modeltablerefer->get_allrows_as_array(); .... // code for show in list action $crud->callback_column('collink_noname', array($this,'_linkrelation')); // code for show in add and edit, maybe read $crud->field_type('collink_noname', 'dropdown',$arrayrowsfromtablerefer);... ... function '_linkrelation' ( $vale, $rowf ) { return $arrayrowsfromtablerefer[$vale]; }
3) here idea of model logic:
public function get_allrows_as_array() { query = "select * from ..." ... foreach( $results as $rows) $arrayoflisttolink[$row->collink_naming] = $row->collink_naming . $row->tablerefer; return $arrayoflisttolink }
EXPLANATION:
theres two situations, when are in a form, and when are in a list..
for the list, we made a callback, i mean, on every row, we escaped taking the value, and searching inside an array of keycodes comming from the refer table, this due we cannot made a query to db on each row render
for the form (add or edit), more simple, only we associate the already array of rows comming from the refer table as a dropdown list and that's all
No hay comentarios.:
Publicar un comentario
no stupid winbuntu users allowed!