phpmysqlcodeignitergrocery-crud

Grocery relation sql databases


I use grocery-crud for a simple SQL select

$crud->set_table('lista_ab');
$crud->set_relation('id_ab','lista_ab_term','Expire');

The problem is that it does not make the relation for 'id_ab'

My database looks

CREATE TABLE `lista_ab` (
  `id_ab` int(10) NOT NULL,
  `Subname` varchar(255) DEFAULT NULL,
  `Name` varchar(255) DEFAULT NULL,
  `Inregistrat` date DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `lista_ab_term` (
  `ID` int(10) NOT NULL,
  `id_ab` int(10) DEFAULT NULL,
  `Expire` date DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

In final I want to extract Subname and Expire.


Solution

  • You cannot create dropdown list and show field name of the first table : Subname, but you can have as many fields you like to call from the other table and the syntax is really simple. Just at the 3rd field you will have the symbol { and } . So it will be for example:

    $crud->set_relation('id_ab','lista_ab_term','{Expire} - {ID}');