

how can insert mutiple items
#1
Posted 17 December 2012 - 07:30 PM
[PRODUCT NAME] - [AMOUNT] - [PRICE]
According to the model attached image
#2
Posted 22 December 2012 - 02:55 PM

i have the same problem!
solution??
Thanks!
#3
Posted 24 December 2012 - 06:37 AM
hi!
i have the same problem!
solution??
Thanks!
Please help!
#4
Posted 24 December 2012 - 07:16 AM
#5
Posted 24 December 2012 - 03:50 PM
can yout explain what you want in more details?
Need some help to make a relationship between products and quantity.
Table1: Products
Columns: id , code, unit, name, size , cost , price
-
Table2: qty_products
Columns: id , product_id , warehouse_id , quantity
the relation between products here is id from products and product_id from qty_products
a simple query for this result is:
SELECT p.id, p.code, p.unit, p.name, p.size, p.cost, p.price, s.quantity, s.warehouse_id FROM products p INNER JOIN qty_products s ON s.product_id = p.idthis result i need to translate to Grocery CRUD.
function products() { $crud = new grocery_CRUD(); $crud->set_table('products'); $crud->set_relation('column','table','column'); $output = $crud->render(); $this->_products($output); }
#6
Posted 24 December 2012 - 05:14 PM
http://www.grocerycr...ample-included/
And you can find more info in this forum
#7
Posted 24 December 2012 - 05:44 PM
You can create and use your model.
http://www.grocerycr...ample-included/
And you can find more info in this forum
Hello Victor,
I'm New in this, and i really don't know from where start, because you are referring for an function db_update and inser, not for a get

Why is so difficulty to implement INNER JOIN ?
To create a new model is really dificulty to insert again the the controller and explode the correct data.
Thanks,
Dario
#8
Posted 24 December 2012 - 06:10 PM
Controller:
function productsinstock() { $crud = new grocery_CRUD(); $crud->set_model('MY_grocery_Model'); $output = $crud->render(); $this->load->view('commons/header', $meta); $this->_produse($output); $this->load->view('commons/footer'); }
Model:
class MY_grocery_Model extends grocery_CRUD_Model{ function getonlyinstock() { $sql = 'SELECT p.id, p.code, p.unit, p.name, p.size, p.cost, p.price, s.quantity, s.warehouse_id FROM products p INNER JOIN warehouses_products s ON s.product_id = p.id'; $query = $this->db->query($sql); $result = $query->result(); return $result; }
What is wrong?
Thanks
#10
Posted 24 December 2012 - 08:22 PM
http://www.grocerycr...64-join-tables/ may be this info help you
Thanks Victor,
Solution is below.
DB:
Table1: Products Columns: id, code, unit, name, size, price Table2: Qty_products Columns: id, product_id, location, quantity
the same id are ( id from products and product_id from qty_products).
Controller:
function productsinstock() { $crud = new grocery_CRUD(); $crud->set_model('my_grocery_model'); $crud->set_table('products'); $crud->columns('id','code','unit','name','size','price','quantity'); $crud->required_fields('name'); $crud->unset_columns('id'); # I think that this fields is in plus $crud->fields('id','code','unit','name','size','price','quantity'); $crud->set_subject('Products'); $output = $crud->render(); $this->_produse($output); }
Model:
function get_list() { if($this->table_name === null) return false; $select = "{$this->table_name}.*"; $select .= ", qty_products.*"; if(!empty($this->relation)) foreach($this->relation as $relation) { list($field_name , $related_table , $related_field_title) = $relation; $unique_join_name = $this->_unique_join_name($field_name); $unique_field_name = $this->_unique_field_name($field_name); if(strstr($related_field_title,'{')) $select .= ", CONCAT('".str_replace(array('{','}'),array("',COALESCE({$unique_join_name}.",", ''),'"),str_replace("'","\\'",$related_field_title))."') as $unique_field_name"; else $select .= ", $unique_join_name.$related_field_title as $unique_field_name"; if($this->field_exists($related_field_title)) $select .= ", {$this->table_name}.$related_field_title as '{$this->table_name}.$related_field_title'"; } $this->db->select($select, false); $this->db->join('qty_products','qty_products.id = '. $this->table_name . '.id'); $results = $this->db->get($this->table_name)->result(); return $results; } }
I hope that this help other people that want to inner join another table. or get another column from different id column name.
#11
Posted 15 April 2013 - 09:30 PM
Couldnt quite get the above to work. So slightly tweaked example:
function getJoinedItems() { $crud = new grocery_CRUD(); $CI =& get_instance(); $CI->join = array('user_id','user_profile','user_id'); $crud->set_model('gc_join_model'); $crud->set_theme('datatables'); $crud->set_table('users'); $crud->set_subject('Users'); $crud->columns('first_name','last_name','cy'); $output = $crud->render(); plugin('grocery_crud',$output); return $output->output; }
class Gc_join_model extends grocery_CRUD_Model { function get_list() { list($field_name, $related_table, $related_field_name) = $this->join; $select = "{$this->table_name}.*,$related_table.*"; if(!empty($this->relation)) { foreach($this->relation as $relation) { list($field_name , $related_table , $related_field_title) = $relation; $unique_join_name = $this->_unique_join_name($field_name); $unique_field_name = $this->_unique_field_name($field_name); if(strstr($related_field_title,'{')) { $select .= ", CONCAT('".str_replace(array('{','}'),array("',COALESCE({$unique_join_name}.",", ''),'"),str_replace("'","\'",$related_field_title))."') as $unique_field_name"; } else { $select .= ", $unique_join_name.$related_field_title as $unique_field_name"; } if($this->field_exists($related_field_title)) { $select .= ", {$this->table_name}.$related_field_title as '{$this->table_name}.$related_field_title'"; } } } $this->db->select($select, false); $this->db->join("$related_table","$related_table.$related_field_name = {$this->table_name}.$field_name"); $results = $this->db->get($this->table_name)->result(); return $results; } }
#12
Posted 15 April 2013 - 09:46 PM
try this. This is running now.
Edited by BalaPerdida, 15 April 2013 - 10:15 PM.
#13
Posted 31 July 2018 - 04:54 AM
Try the Dependent dropdown list like: https://www.groceryc...opdown-library/
OR:
https://www.groceryc..._a_relation_n_n
Also tagged with one or more of these keywords: insert, multiple, items, relation
Support →
Grocery CRUD Enterprise →
Join fields from different tables within one fieldStarted by Manuel, 26 Nov 2020 ![]() |
|
![]() |
||
Support →
Grocery CRUD Enterprise →
Column not found: 1054 Unknown column in where clauseStarted by ajuser, 12 Feb 2020 ![]() |
|
![]() |
||
Support →
I have a question →
I have a problem with a callbackStarted by Leandro Oliveira, 02 Sep 2019 ![]() |
|
![]() |
||
Support →
I have a question →
How to work with JoinStarted by rsingh0071, 12 Aug 2019 ![]() |
|
![]() |
||
Support →
I have a question →
How to build thisStarted by holmesii, 13 Jun 2018 ![]() |
|
![]() |
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users