How to count the number of rows with a date from a certain year in CodeIgniter?
10:51 26 Feb 2015

I have the following query.

$query = $this->db->query('SELECT COUNT(*) FROM iplog.persons WHERE begin_date LIKE '2014%'');

I need to count the number of columns with a begin_date in the year 2014.

When I run this script I'm getting an error:

Parse error: syntax error, unexpected '2014' (T_LNUMBER) in C:\xampp\htdocs\iPlog2\application\controllers\stat.php on line 12

I was trying to change my CI script to

$query = $this->db->query('SELECT COUNT(*) FROM iplog.persons WHERE begin_date LIKE "2014%"');

but it caused an error.

php date codeigniter select counting