![]() |
Installation Tables and Columns Help...
Okay, lets say I have a mod... and in version1, I have the following install code... (the code is an example, I know its not functioning, but thats got nothing to do with my problem)
Code:
$db->query_write("CREATE TABLE IF NOT EXISTS table ( Then I create a version2, with an extra column... so I made my install code this... Code:
$db->query_write("CREATE TABLE IF NOT EXISTS table ( Now I am making a version 3... and there is yet another column to add... I tried the following code, but I got an error when it hit the ADD COLUMN column3 code... because column3 already exists. Code:
$db->query_write(" |
You could run a query to retrieve the columns in "table" and then control the flow of logic from there.
PHP Code:
|
Hmm... how would that code be written exactly? What would be the code to construct $columns?
|
PHP Code:
|
Huh? I'm confused? What would I need to loop? Wouldn't this be enough?
Code:
$columns = $db->query_read("SHOW COLUMNS FROM table"); |
If you look at what $columns contains, you'll see it is a two-dimensional array. You need to loop through it after your query to extract the relevant information; in this case - the field names.
PHP Code:
|
There is a reason why you are allowed to create multiple install codes in products. In the version 1 install code, use the first query. In the version 2 code, create a query using ALTER and add another column. In the version 3 install code, create another query.
On a new installation of the modification, vBulletin will run the install codes in order of version. |
So this this shoudl work? the table name is video... and the column is timelength...
Code:
$columns = $db->query_read("SHOW COLUMNS FROM video"); |
Why not use the install code functionality now?
|
Because what if someone is upgrading from Version 1 to Version 3... They wont get the changes in Version 2, because its not in the new install code. If I put the new install code in Version 3; then it gets the redundancy error.
Anyway, the code worked, thanks Kirk! |
All times are GMT. The time now is 02:19 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|