I am running a query where $sale_ids
could potentially contain 100's to a thousands of sale_ids. I am looking for a way to fix the regex error without modifying the core of CI 3.
This didn't happen in version 2 and is NOT considered a bug in CI 3 (I brought up the issue before).
Is there a way I can get this to work? I could change the logic of the application but this would require days of work.
I am looking for a way to extend/override a class so I can allow for this query to work If there is not a way to do this by override I will have to hack the core (I don't know how).
$this->db->select('sales_payments.*, sales.sale_time');
$this->db->from('sales_payments');
$this->db->join('sales', 'sales.sale_id=sales_payments.sale_id');
$this->db->where_in('sales_payments.sale_id', $sale_ids);
$this->db->order_by('payment_date');
Error is:
Severity: Warning
Message: preg_match(): Compilation failed: regular expression is too large at offset 53249
Filename: database/DB_query_builder.php
Line Number: 2354
Backtrace:
File: /Applications/MAMP/htdocs/phppos/PHP-Point-Of-Sale/application/models/Sale.php
Line: 123
Function: get
File: /Applications/MAMP/htdocs/phppos/PHP-Point-Of-Sale/application/models/Sale.php
Line: 48
Function: _get_all_sale_payments
File: /Applications/MAMP/htdocs/phppos/PHP-Point-Of-Sale/application/models/reports/Summary_payments.php
Line: 60
Function: get_payment_data
File: /Applications/MAMP/htdocs/phppos/PHP-Point-Of-Sale/application/controllers/Reports.php
Line: 1887
Function: getData
File: /Applications/MAMP/htdocs/phppos/PHP-Point-Of-Sale/index.php
Line: 323
Function: require_once
There wasn't a good way to modify the core so I came up with a small change that I made to the code with large where_in's. Start a group and create where where_in's in smaller chunks
$this->db->group_start();
$sale_ids_chunk = array_chunk($sale_ids,25);
foreach($sale_ids_chunk as $sale_ids)
{
$this->db->or_where_in('sales_payments.sale_id', $sale_ids);
}
$this->db->group_end();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With