I am rather new to both CodeIgniter and GroceryCRUD. So, I wanted to ask if this code listed below is stable. This is a MASTER-DETAIL system which appears to be working with a few records.
First of all, here is are the two tables - the master table (invoices) and the detail table (invoicesx):
CREATE TABLE `invoices` (
`refno` varchar(10) NOT NULL DEFAULT '',
`date` date DEFAULT NULL,
`custcode` varchar(10) NOT NULL,
`agent` varchar(10) NOT NULL,
PRIMARY KEY (`refno`),
KEY `custcode` (`custcode`),
KEY `agent` (`agent`),
CONSTRAINT `invoices_ibfk_1` FOREIGN KEY (`custcode`) REFERENCES `customers` (`custcode`),
CONSTRAINT `invoices_ibfk_2` FOREIGN KEY (`agent`) REFERENCES `agents` (`agent`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
`id` int(11) NOT NULL AUTO_INCREMENT,
`refno` varchar(10) NOT NULL DEFAULT '',
`lineno` int(4) NOT NULL,
`itemcode` varchar(10) NOT NULL,
`qty` int(5) NOT NULL,
`price` decimal(12,2) DEFAULT '0.00',
PRIMARY KEY (`id`),
KEY `itemcode` (`itemcode`),
CONSTRAINT `invoicesx_ibfk_1` FOREIGN KEY (`itemcode`) REFERENCES `items` (`itemcode`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8
Initially I used a detail table using the RefNo and LineNo fields as the primary key. However, my tests showed that grocerycrud doesn't seem to handle MASTER-DETAIL correctly when the detail table consists of a primary key with compound fields. So, I created id as the primary key and everything worked. But, I am not sure if there are loopholes that need to be addressed.
This function resides in invoices.php:
public function assemble()
These functions reside in invoicesd.php:
To summarize:
1. invoices.php shows a list of records for the MASTER table - Invoices table. I inserted an add_action function like so:
$gcrud->add_action('Details',base_url().'images/detail.png','invoicesd/assemble');
2. invoices.php shows a list of records for the DETAIL table - Invoicesx table. It takes on a single parameter which is the primary key field of the previous table, like so:
public function assemble($pk)
3. I filtered the detail table and arranged the records by lineno field:
4. then I hid the refno field while giving it the default value of the primary key value of the master table:
My question is this: Is there a way to make all these more efficient since this both MASTER and DETAIL tables are expected to get really large very fast, with a size of around 50,000 records for the detail table. There would be separate tables for master and detail records for a single year. I am guessing that I need to do something more to improve on the performance of the code over time.
Thanks in advance.
Ed