Permalink
Browse files

Fixed recent change to $this->db->field_data() which errored for fiel…

…d types without constraints. It now uses a less expecting regex and defaults to NULL.
  • Loading branch information...
1 parent b4009e2 commit 4c907236af3b6dc11a7b4989ece1c84a26483c46 Phil Sturgeon committed Aug 28, 2011
@@ -86,10 +86,10 @@ function field_data()
$retval = array();
while ($field = mysql_fetch_object($this->result_id))
{
- preg_match('/([a-zA-Z]+)\((\d+)\)/', $field->Type, $matches);
+ preg_match('/([a-zA-Z]+)(\((\d+)\))?/i', $field->Type, $matches);
$type = $matches[1];
- $length = (int)$matches[2];
+ $length = isset($matches[3]) ? (int) $matches[3] : NULL;
$F = new stdClass();
$F->name = $field->Field;
@@ -86,10 +86,10 @@ function field_data()
$retval = array();
while ($field = mysqli_fetch_object($this->result_id))
{
- preg_match('/([a-zA-Z]+)\((\d+)\)/', $field->Type, $matches);
+ preg_match('/([a-zA-Z]+)(\((\d+)\))?/i', $field->Type, $matches);
$type = $matches[1];
- $length = (int)$matches[2];
+ $length = isset($matches[3]) ? (int) $matches[3] : NULL;
$F = new stdClass();
$F->name = $field->Field;

0 comments on commit 4c90723

Please sign in to comment.