Feeds, issues, packages and code source about emulation and pograming, of VENENUX proyects, Debian related distros and massenkoh!

Codeigniter: grocerycrud asociation 1-1 with a custom query, dropdown list, column asociation

(under construction) NO AJAX COMPLICATIONS; only pure php and grocery crud

* 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

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

0 comments/comentarios:

Publicar un comentario

si vienes de guindo, winbuntu o parecido, limitate y escribe algo util...