diff options
author | Christian Schneider | 2007-07-15 09:35:08 +0000 |
---|---|---|
committer | Christian Schneider | 2007-07-15 09:35:08 +0000 |
commit | ece30e7e6d98ee2e8050ee493d79d63efc6f1d5e (patch) | |
tree | 01ee557c4c2f6295e00a53d4759218f4305c63ec /dbi.class | |
parent | 0b34b03a158da609178ae1e885b47dc9a4d67d3d (diff) | |
download | itools-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.class | 50 |
1 files changed, 25 insertions, 25 deletions
@@ -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); + } } - } - "); + "); + } } } } |