mattmcc
07-29-2009, 08:14 PM
I'm new to vBulletin but have PHP experience. I'm trying to create a mod. In my exported XML file I have the following:
<installcode><![CDATA[
require_once(DIR . '/global.php');
$db->hide_errors();
$sql_create = "CREATE TABLE IF NOT EXISTS `" . TABLE_PREFIX . "myproduct_settings` ( ...
$vbulletin->db->query_write($sql_create);
$db->show_errors();
]]></installcode>
When I install the product through admincp and check my database, the table has not been created. What call do I need to make to create a table? I find the API documentation very confusing.
Also, how can I get debug information? I added the line:
$config['Misc']['debug'] = true;
into my config.php file as suggested in another thread but do not see any output anywhere.
Thanks
--------------- Added 1248907863 at 1248907863 ---------------
An update about this. I found a few other posts on the forum where they also couldn't add a new table upon installation with no useful replies.
As a test, I took the exact code that was in the installation and put it in a new test.php file. When I ran the PHP file, it worked correctly.
Is there a reason that vBulletin would not allow new tables to be created for products or is this just a bug? How do I go about reporting a bug if it is?
--------------- Added 1248910795 at 1248910795 ---------------
Oh geez, after looking through the vBulletin code for Importing a new Product in plugin.php I realized that the <installcode> only gets executed if the version is * or the current version is null or the version is newer.
I was keeping 1.0 in the version box the whole time. After changing it to '*', the code executed correctly (I must have had some kind of error in the first version I originally used). Argh! There goes half a day.
<installcode><![CDATA[
require_once(DIR . '/global.php');
$db->hide_errors();
$sql_create = "CREATE TABLE IF NOT EXISTS `" . TABLE_PREFIX . "myproduct_settings` ( ...
$vbulletin->db->query_write($sql_create);
$db->show_errors();
]]></installcode>
When I install the product through admincp and check my database, the table has not been created. What call do I need to make to create a table? I find the API documentation very confusing.
Also, how can I get debug information? I added the line:
$config['Misc']['debug'] = true;
into my config.php file as suggested in another thread but do not see any output anywhere.
Thanks
--------------- Added 1248907863 at 1248907863 ---------------
An update about this. I found a few other posts on the forum where they also couldn't add a new table upon installation with no useful replies.
As a test, I took the exact code that was in the installation and put it in a new test.php file. When I ran the PHP file, it worked correctly.
Is there a reason that vBulletin would not allow new tables to be created for products or is this just a bug? How do I go about reporting a bug if it is?
--------------- Added 1248910795 at 1248910795 ---------------
Oh geez, after looking through the vBulletin code for Importing a new Product in plugin.php I realized that the <installcode> only gets executed if the version is * or the current version is null or the version is newer.
I was keeping 1.0 in the version box the whole time. After changing it to '*', the code executed correctly (I must have had some kind of error in the first version I originally used). Argh! There goes half a day.