- Hello i am also new to Codeigniter and Grocery Crud but is a great design
My question is i think maybe a little advanced but curious on how to create a custom function similar to the below
code.
The function and controller i would like to get an answer to is how to store mutiple records for a single user_id
in other words on the main screen for records i only need 1 user_id shown in the records area based on user_id table
in sql ?
I am comfrotable with SQL but having problems deciding how to display mutiple records for only 1 user_id
The database is going to be for patient forms and the patient can only view there records only but each patient
will need multiple consultations recorded.
SELECT * FROM user_id
the above statement is the basis of what i need -- what i presume i need is a mutiple array passed as data
but how would you access that with above SELECT statement ?
Thank you in advance
spending to many hours trying for solutions !
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class Custom_query_model extends grocery_CRUD_model {
- private $query_str = '';
- function __construct() {
- parent::__construct();
- }
- function get_list() {
- $query=$this->db->query($this->query_str);
- $results_array=$query->result();
- return $results_array;
- }
- public function set_query_str($query_str) {
- $this->query_str = $query_str;
- }
- }
Step 2. Code the controller
Add the following code to your controller and existing mechanic for outputting the Grocery CRUD interface.
$crud = new grocery_CRUD();
$crud->set_model('custom_query_model');
$crud->set_table('employees'); //Change to your table name
$crud->basic_model->set_query_str('SELECT * FROM employees'); //Query text here
$output = $crud->render();