Form_validation is_unique issue #1572

Closed
covrigadrian opened this Issue Jul 4, 2012 · 3 comments

Comments

Projects
None yet
2 participants
@covrigadrian

Hi,

I'm using Firebird an i have a problem with form_validation->is_unique function. This function uses the $query->num_rows() and this function doesn't return the correct number of rows, so I've change the is_unique function to this:
public function is_unique($str, $field)
{
list($table, $field) = explode('.', $field);
if (isset($this->CI->db))
{
$query = $this->CI->db->limit(1)->get_where($table, array($field => $str));
$rows = $query->result_array();
return count($rows) === 0;
}
return FALSE;
}
I think this implementation is better for all the database drivers.

@narfbg

This comment has been minimized.

Show comment Hide comment
@narfbg

narfbg Jul 4, 2012

Contributor

Why not try to fix the num_rows() method instead?

Contributor

narfbg commented Jul 4, 2012

Why not try to fix the num_rows() method instead?

@covrigadrian

This comment has been minimized.

Show comment Hide comment
@covrigadrian

covrigadrian Jul 4, 2012

The only way to do this is to fetch all the rows an count them. Yes this is a good solution.

The only way to do this is to fetch all the rows an count them. Yes this is a good solution.

@narfbg

This comment has been minimized.

Show comment Hide comment
@narfbg

narfbg Jul 5, 2012

Contributor

Just did a long list of changes to the DB result classes today and this issue should be fixed. Can you try with the latest code and confirm it?
If you've used the 'interbase' driver, have in mind that it's renamed to 'ibase'.

Contributor

narfbg commented Jul 5, 2012

Just did a long list of changes to the DB result classes today and this issue should be fixed. Can you try with the latest code and confirm it?
If you've used the 'interbase' driver, have in mind that it's renamed to 'ibase'.

@narfbg narfbg closed this Oct 5, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment