<install>
<![CDATA[
// Adding SQL statement / creating table /installation code
$schema = array(
'FIELDS' => array(
'id' => array(
'datatype' => 'SERIAL',
'allow_null' => false
),
'cat_name' => array(
'datatype' => 'VARCHAR(80)',
'allow_null' => false,
'default' => '\'o_ratings_category\''
),
'disp_position' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
'default' => '0'
)
),
'PRIMARY KEY' => array('id')
);
$forum_db->create_table('ratings', $schema);
]]>
</install>
well that depends; I have PRIMARY KEY ip , page that need to be added
that is kind of my question, how to add those properly...
see in include/rate.php afterwards I use
function rate()
{
$star_value = forum_htmlencode($_GET['r']);
$page = forum_htmlencode($_GET['p']);
$ip = $_SERVER['REMOTE_ADDR'];
//Add to database
$query = array(
'INSERT' => 'ip, rating, page',
'INTO' => DB_TABLE,
'VALUES' => $ip.', '.$star_value.', '.$page
);
$forum_db->query_build($query) or error(__FILE__, __LINE__);
$ref = $_SERVER['HTTP_REFERER'];
redirect($ref, 'Redirecting, Please wait …');
}
thats where I'm coming from....
EDIT: changed it to this now
<install>
<![CDATA[
// Adding SQL statement / creating table /installation code
if(!$forum_db->table_exists('ratings'))
{
$schema = array(
'FIELDS' => array(
'id' => array(
'datatype' => 'SERIAL',
'allow_null' => false
),
'cat_name' => array(
'datatype' => 'VARCHAR(80)',
'allow_null' => false,
'default' => '\'o_ratings_category\''
),
'disp_position' => array(
'datatype' => 'INT(10)',
'allow_null' => false,
'default' => '0'
)
),
'PRIMARY KEY' => array('id')
);
$forum_db->create_table('ratings', $schema);
}
]]>
</install>
<uninstall><![CDATA[
// Uninstallation code
$forum_db->query('DELETE FROM '.$forum_db->prefix.'config WHERE conf_name = "o_ratings_category");
$forum_db->drop_table('ratings');
]]></uninstall>
but I need advice on how to get consistency between manifest.xml and include/rate.php !