• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2 questions: error404 handling and regular expressions in db..


I have two questions, so I put them here together:

1.) If I have a path like this: http://mysite.com/id/20
And if I enter some nonexistent id (for example http://mysite.com/id/160) I get a php error. What can I do to get the error404 page?

2.) I have in the db the column named keywords where I have saved keywords separated by space. And if I want to show all articles with this keyword, how do I pass the regular expression to $this->load->where('');? Or how do I should select them?

Thanks a lot

[eluser]Michael Wales[/eluser]
1. First do some error checking on the id's - if they are non-existant use show_404('page'); You can read about this in the Error Reporting documentation.

2. You could use the like() method. Active Record documentation.
$this->db->like('keywords', ' ' . $query . ' ');

I included the spacing on the query so your matching exact terms. 'put' will only find 'put' and not 'putting'

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.