require_once(dirname(__FILE__).'/db/field.php');
if (!defined('DB_ERR_PRINT')) define('DB_ERR_PRINT',false);
if (!defined('DB_HTML_FORM_BUTTONS')) define('DB_HTML_FORM_BUTTONS',''
- .'<input type="submit" class="button" value="GO"/>'
- .'<a class="button" href="#" onclick="return nb.form_clear(this.parentElement)">X</a>'
.'<input type="submit" class="button" name="edit" value="Add"/>'
+ .'<a class="button" href="#" onclick="return nb.form_clear(this.parentElement)">X</a>'
+ .'<input type="submit" class="button" value="GO"/>'
);
if (!defined('DB_HTML_BUTTON_ADD')) define('DB_HTML_BUTTON_ADD','<input type="submit" class="button" name="edit" value="Add"/>');
if (!defined('DB_HTML_BUTTON_SUBMIT')) define('DB_HTML_BUTTON_SUBMIT','<input type="submit" class="button" value="GO"/>');
$this->conn = new PDO($db['conn']);
if (DB_ERR_PRINT) $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
- err($e->getMessage(), "connecthrsedb");
- return $e;
+ err($e->getMessage(), "Db.new()");
+ return false;
}
#if (empty($this->name)) $this->name = preg_replace('/^(?:(?:sqlite:.*(.*?)(\.\w+)?)|(?:.*?dbname=([^;]+).*?))$/','\1',$db['conn']);
foreach ($rows as $row) {
$this->fields[$row['name']] = array(
- 'extra' => null,
- 'type' => null,
- 'default' => null,
- 'key' => null,
+ 'extra' => null,
+ 'type' => null,
+ 'default' => null,
+ 'key' => null,
+ 'autoincrement' => false,
);
$this->fields[$row['name']]['type'] = $row['type'];
if (!$where) return 0;
$sql = 'DELETE FROM ' . $this->sql_name() . $where;
debug($sql);
- $execute = $this->db->query($sql);
- if (!$execute) return err('PDO::errorInfo(): ' .join(' ', $this->db->conn->errorInfo()) .PHP_EOL);
- return $execute;
+ try {
+ $this->db->query($sql);
+ } catch (PDOException $e) {
+ return err($e->getMessage(), "Table.delete()");
+ }
+ return true;
}
}