2010-08-27, 04:15 PM
Okay, so MyBB supports MySQL/i, PgSQL, and SQLite. I need to know if this code is compatible with all these types> Mostly I am unsure of the PgSQL
It works fine in MySQL and MySQLi and I assume that its valid for SQLite, but not sure about pgSQL
$create_sql = "CREATE TABLE `".TABLE_PREFIX."garage_data".$mybb->input['id']."` (
`gid` smallint(10) NOT NULL auto_increment,
`uid` int(10) NOT NULL,
`views` int(11) NOT NULL default '0',
`comments` int(11) NOT NULL default '0',
`submit_date` varchar(20) default '',
`dateline` bigint(30) NOT NULL,
`createdate` bigint(30) NOT NULL default '0',
`approved` tinyint(1) NOT NULL default '0',
`approved_by` mediumint(10) NOT NULL default '0',
`posthash` varchar(32) NOT NULL default '',";
$create_index = " PRIMARY KEY (`gid`),
KEY `uid` (`uid`),
KEY `approved` (`approved`)";
while($result = $db->fetch_array($query))
{
if($result['field_type'] == 'int')
{
$create_sql .= '`'.$result['name'].'` int('.$result['data_length'].') default \'0\',';
}
if($result['field_type'] == 'bigint')
{
$create_sql .= '`'.$result['name'].'` bigint('.$result['data_length'].') default \'0\',';
}
if($result['field_type'] == 'varchar')
{
$create_sql .= '`'.$result['name'].'` varchar('.$result['data_length'].') default \'\',';
}
if($result['field_type'] == 'text')
{
$create_sql .= '`'.$result['name'].'` text,';
}
if($result['field_type'] == 'timestamp')
{
$create_sql .= '`'.$result['name'].'` timestamp,';
}
if($result['require'] == 1)
{
$create_index .= ", KEY `".$result['name']."` (`".$result['name']."`)";
}
}
$create_index .= ")";
if($db->type == 'mysql' || $db->type == 'mysqli')
{
$create_mysql = " ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=1 AUTO_INCREMENT=1";
}
$create_sql = $create_sql.$create_index.$create_mysql.";";
It works fine in MySQL and MySQLi and I assume that its valid for SQLite, but not sure about pgSQL