General Community > Scripting Help
myseql Database Field - How to add a field in?
The Wizard:
Hello:
I'm working on a small item mod for the SMF shop and I need to add a field to the database. Below is the code I have so far but it's not working as I checked my database the the field does not exist. can anyone tell me where I went wrong with the code?
Thanks
Wiz
--- Quote ---if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');
// Hmm... no SSI.php and no SMF?
elseif (!defined('SMF'))
die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
//The Flag field in the member table
$smcFunc['db_query']('', 'ALTER TABLE `{$db_prefix}members` ADD `shop_Dog` TEXT NOT NULL', __FILE__, __LINE__);
//Add the item
$smcFunc['db_query']('', "INSERT INTO `{$db_prefix}shop_items` (`name` , `desc` , `price` , `module` , `stock`, `input_needed`, `can_use_item`) VALUES ('Dog Image', 'Show an image next to your posts', '100.00', 'Dog', '50', 1, 1')", __FILE__, __LINE__);
--- End quote ---
Arantor:
Use the db_add_column function, not a manual ALTER TABLE. It's documented in the coding board.
The Wizard:
Could you please post a example? This myseql stuff is way over my head. Sorry still learning.
Arantor:
That's why I pointed out the Coding Discussion board. There's a topic in there that documents - with examples - all the functions.
The Wizard:
I'm afraid there are no examples for package functions.
Navigation
[0] Message Index
[#] Next page
Go to full version