preg_match Compilation failed: regular expression is too large at offset 106036 - bmccrae - 06-13-2018
Code: for ($ci = 0, $cc = count($conditions); $ci < $cc; $ci++)
{
if (($op = $this->_get_operator($conditions[$ci])) === FALSE
OR ! preg_match('/^(\(?)(.*)('.preg_quote($op, '/').')\s*(.*(?<!\)))?(\)?)$/i', $conditions[$ci], $matches))
{
continue;
}
// $matches = array(
// 0 => '(test <= foo)', /* the whole thing */
// 1 => '(', /* optional */
// 2 => 'test', /* the field name */
// 3 => ' <= ', /* $op */
// 4 => 'foo', /* optional, if $op is e.g. 'IS NULL' */
// 5 => ')' /* optional */
// );
if ( ! empty($matches[4]))
{
$this->_is_literal($matches[4]) OR $matches[4] = $this->protect_identifiers(trim($matches[4]));
$matches[4] = ' '.$matches[4];
}
$conditions[$ci] = $matches[1].$this->protect_identifiers(trim($matches[2]))
.' '.trim($matches[3]).$matches[4].$matches[5];
}
Has anyone solved this issue with preg_match() function? HELP
Message: preg_match(): Compilation failed: regular expression is too large at offset 106036
Filename: database/DB_query_builder.php
RE: preg_match Compilation failed: regular expression is too large at offset 106036 - jreklund - 06-13-2018
We need the actual code you are using to get that error message.
RE: preg_match Compilation failed: regular expression is too large at offset 106036 - bmccrae - 06-14-2018
Code: Here's the code...
function my_page()
{
$userinfo = $this->plan->user_info();
$toget = array();
$toshow = '';
$returnpage = '';
if ($userinfo['office'] !== '1') {
redirect('plan');
}
if ($this->uri->segment(3) == 'archived') {
$this->db->where('archived','1');
$pagetitle = '<h2>All Archived Courses</h2>';
$archiveswitch = '<p>'.anchor('plan/admin','Review non-archived courses').'</p>';
} else {
$this->db->where('archived','0');
$pagetitle = '<h2>All Courses</h2>';
$archiveswitch = '<p>'.anchor('plan/admin/archived','Review archived courses').'</p>';
}
$this->db->order_by('service_line ASC, technical_title ASC, ID DESC');
$foundthem = $this->db->get('planning_course');
if ($foundthem->num_rows() > 0) {
foreach ($foundthem->result_array() as $thiscourse) {
$toshow .= '<p><strong>';
$toshow .= $thiscourse['service_line'].$thiscourse['audience'].'_'.$thiscourse['strategy'].'__: ';
$usetitle = $thiscourse['planning_title'];
if ($thiscourse['technical_title'] !== '') { $usetitle = $thiscourse['technical_title']; }
$toshow .= $usetitle;
$toshow .= '</strong><br>';
$this->db->where('course_ID',$thiscourse['ID']);
$this->db->where('removed','0');
$this->db->order_by('on_date ASC');
$founddays = $this->db->get('planning_day');
if ($founddays->num_rows() > 0) {
$datelist = '';
foreach ($founddays->result_array() as $thisday) {
if ($datelist !== '') { $datelist .= ', '; }
$datelist .= '<em>'.$thisday['eventID'].'</em>';
}
$toshow .= $datelist.'<br>';
} else {
$toshow .= '<em>No dates scheduled</em><br>';
}
$people = array();
$this->db->where('course_ID',$thiscourse['ID']);
$this->db->order_by('role ASC');
$foundroles = $this->db->get('planning_role');
if ($foundroles->num_rows() > 0) {
foreach ($foundroles->result_array() as $thisrole) {
$people[$thisrole['role']][] = $thisrole['person_ID'];
}
}
foreach ($people as $role=>$peopleIDs) {
$showpeople = '';
$this->db->where_in('ID',$peopleIDs);
$this->db->order_by('LN ASC, FN ASC, ID ASC');
$foundpeople = $this->db->get('planning_person');
if ($foundpeople->num_rows() > 0) {
foreach ($foundpeople->result_array() as $thisperson) {
if ($showpeople !== '') { $showpeople .= '; '; }
if ($showpeople == '') {
$showpeople .= '<strong>'.strtoupper(substr($role,0,1)).substr($role,1);
if ($foundpeople->num_rows() > 1) { $showpeople .= 's'; }
$showpeople .= ':</strong> ';
}
$showpeople .= $thisperson['email_address'];
}
$showpeople .= '<br>';
}
$toshow .= $showpeople;
}
$toshow .= anchor('plan/course/'.$thiscourse['ID'],'Review this course').'</p>';
}
}
$returnpage .= $pagetitle;
$returnpage .= $archiveswitch;
$returnpage .= $toshow;
return $returnpage;
}
RE: preg_match Compilation failed: regular expression is too large at offset 106036 - bmccrae - 06-15-2018
Brian 6/15/2018 - Fixed by adding a where clause to the PHP query to restrict the number of records returned from a large table.
|