Welcome Guest, Not a member yet? Register   Sign In
Custom form validation rule
#7

I'm not great with RegEx, so I would usually go with something like this:
PHP Code:
$fields explode(':'$field);
list(
$table$field) = explode('.'$fields[0], 2);
$ignore = isset($fields[1]) ? $fields[1] : null

This code will work whether a colon is passed in the $field or not, but there is potential for issues if the string doesn't contain a table.field combination (either before the colon or without one), so you may need some additional code if that is a possibility. Generally, unless I need something fairly complex, explode() is easier to understand and gets predictable results.

Also, instead of:
PHP Code:
return $this->CI->db->num_rows() === 0

You may want to use something like this:
PHP Code:
$row $this->CI->db->get()->row();
return ! isset(
$row); 

After all, you don't really care how many rows were returned, and, if num_rows() works at all the way you're using it, it's very likely to be getting the full result set and counting it, rather than using a method provided by the database to determine how many rows were returned by a query.
Reply


Messages In This Thread
Custom form validation rule - by jLinux - 08-29-2015, 11:20 AM
RE: Custom form validation rule - by jLinux - 08-30-2015, 09:00 AM
RE: Custom form validation rule - by CroNiX - 08-30-2015, 09:02 AM
RE: Custom form validation rule - by jLinux - 08-30-2015, 10:14 AM
RE: Custom form validation rule - by mwhitney - 08-31-2015, 09:35 AM
RE: Custom form validation rule - by jLinux - 09-05-2015, 10:07 AM
RE: Custom form validation rule - by mwhitney - 09-08-2015, 07:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB