public $sequence_only = true; //To avoid to output the rest of the field specs, leaving only the name and the sequence_name publiciable
public $sequence_extra_code = false; //Does the generator need to add extra code to generate the sequence fields
- public $sequence_name = 'INTEGER PRIMARY KEY AUTOINCREMENT'; //Particular name for inline sequences in this generator
+ public $sequence_name = 'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'; //Particular name for inline sequences in this generator
public $unsigned_allowed = false; // To define in the generator must handle unsigned information
public $enum_extra_code = false; //Does the generator need to add extra code to generate code for the enums in the table
*/
public function get_tables() {
$tables = array();
- $sql = 'SELECT name FROM sqlite_master WHERE type="table"';
+ $sql = 'SELECT name FROM sqlite_master WHERE type="table" ORDER BY name';
if($this->debug) {
$this->debug_query($sql);
}
*/
public function get_indexes($table) {
$indexes = array();
- $sql = 'SELECT * FROM sqlite_master WHERE type="index" AND tbl_name="'. $this->prefix . $table . '"';
+ $sql = 'PRAGMA index_list('. $this->prefix . $table . ')';
if($this->debug) {
$this->debug_query($sql);
}
$rsindexes = $this->pdb->query($sql);
foreach($rsindexes as $index) {
- $index = strtolower($index['name']);
+ $unique = (boolean)$index['unique'];
+ $index = $index['name'];
$sql = 'PRAGMA index_info("' . $index . '")';
if($this->debug) {
$this->debug_query($sql);
$columns[] = strtolower($row['name']);
}
$index = strtolower($index);
+ $indexes[$index]['unique'] = $unique;
$indexes[$index]['columns'] = $columns;
}
return $indexes;
'primary_key' => (boolean)$row['pk'],
'has_default' => !is_null($row['dflt_value']),
'default_value' => $row['dflt_value'],
+ 'auto_increment' => false,
+ 'binary' => false,
+ //'unsigned' => false,
);
$type = explode('(', $row['type']);
$columninfo['type'] = strtolower($type[0]);
case 'int': // int integer
if($columninfo['primary_key'] && preg_match('/' . $columninfo['name'] . '\W*integer\W*primary\W*key\W*autoincrement/im', $createsql)) {
$columninfo['meta_type'] = 'R';
+ $columninfo['auto_increment'] = true;
} else {
$columninfo['meta_type'] = 'I';
}
case 'blo': // blob
case 'non': // none
$columninfo['meta_type'] = 'B';
+ $columninfo['binary'] = true;
break;
case 'boo': // boolean
case 'bit': // bit
case 'log': // logical
$columninfo['meta_type'] = 'L';
+ $columninfo['max_length'] = 1;
break;
case 'tim': // timestamp
$columninfo['meta_type'] = 'T';
$columninfo['meta_type'] = 'D';
break;
}
-
$columns[$columninfo['name']] = new database_column_info($columninfo);
}