summaryrefslogtreecommitdiff
path: root/dbi.class
diff options
context:
space:
mode:
authorChristian Schneider2007-07-15 09:35:08 +0000
committerChristian Schneider2007-07-15 09:35:08 +0000
commitece30e7e6d98ee2e8050ee493d79d63efc6f1d5e (patch)
tree01ee557c4c2f6295e00a53d4759218f4305c63ec /dbi.class
parent0b34b03a158da609178ae1e885b47dc9a4d67d3d (diff)
downloaditools-ece30e7e6d98ee2e8050ee493d79d63efc6f1d5e.tar.gz
itools-ece30e7e6d98ee2e8050ee493d79d63efc6f1d5e.tar.bz2
itools-ece30e7e6d98ee2e8050ee493d79d63efc6f1d5e.zip
Skip creating classes for tables where list_fields fails: Does not matter if table not used, otherwise will give class undefined error
Diffstat (limited to 'dbi.class')
-rw-r--r--dbi.class50
1 files changed, 25 insertions, 25 deletions
diff --git a/dbi.class b/dbi.class
index 853470b..727f3a9 100644
--- a/dbi.class
+++ b/dbi.class
@@ -107,38 +107,38 @@ function it_dbi($config, $query = null)
$table = mysql_tablename($tables, $i);
$classname = "$this->_classprefix$table";
- if (!($result = @mysql_list_fields($this->_db, $table, $this->_link)))
- $this->_fatal("it_dbi(): can't list fields \"$this->_db\": " . mysql_error($this->_link));
-
- for ($fields=array(), $j=0; $j < mysql_num_fields($result); $j++)
+ if ($result = @mysql_list_fields($this->_db, $table, $this->_link))
{
- $fields[mysql_field_name($result, $j)] = mysql_field_len($result, $j);
- $flags = mysql_field_flags($result, $j);
-
- if (strstr($flags, "primary_key"))
+ for ($fields=array(), $j=0; $j < mysql_num_fields($result); $j++)
{
- $keyfield = mysql_field_name($result, $j);
- $autoincrement = (bool)strstr($flags, "auto_increment");
- $randomid = (mysql_field_type($result, $j) == "string");
+ $fields[mysql_field_name($result, $j)] = mysql_field_len($result, $j);
+ $flags = mysql_field_flags($result, $j);
+
+ if (strstr($flags, "primary_key"))
+ {
+ $keyfield = mysql_field_name($result, $j);
+ $autoincrement = (bool)strstr($flags, "auto_increment");
+ $randomid = (mysql_field_type($result, $j) == "string");
+ }
}
- }
- $fields = var_export($fields, true);
+ $fields = var_export($fields, true);
- if ($this->_createclasses && (substr($classname, 0, 4) != 'PMA_') && !class_exists($classname))
- {
- debug("it_dbi: creating class $classname", 5);
- eval("
- class $classname extends it_dbi
- {
- function $classname(\$query = null, \$config = array())
+ if ($this->_createclasses && (substr($classname, 0, 4) != 'PMA_') && !class_exists($classname))
+ {
+ debug("it_dbi: creating class $classname", 5);
+ eval("
+ class $classname extends it_dbi
{
- \$config += array($defaults'table' => '$table', 'keyfield' => '$keyfield', 'autoincrement' => '$autoincrement', 'randomid' => '$randomid');
- \$this->_fields = $fields;
- \$this->it_dbi(\$config, \$query);
+ function $classname(\$query = null, \$config = array())
+ {
+ \$config += array($defaults'table' => '$table', 'keyfield' => '$keyfield', 'autoincrement' => '$autoincrement', 'randomid' => '$randomid');
+ \$this->_fields = $fields;
+ \$this->it_dbi(\$config, \$query);
+ }
}
- }
- ");
+ ");
+ }
}
}
}