General Community > Scripting Help

myseql Database Field - How to add a field in?

<< < (3/4) > >>

The Wizard:
I,m sorry I don't uderstand this part. Whats with all the string-255 ? Please explane?
"Where is my towel when I need it!"



--- Quote --- array(
     'name' => 'string-255', 'desc' => 'string-65534', 'price' => 'string-255', 'module' => 'string-255', 'Stock' => 'int', 'input_needed' => 'int', 'can_use_item' => 'int',
   ),
--- End quote ---

Arantor:
As I said, you have to tell the insert function what data you're sending in and what type it is. The simplest choices are int and string and with a string you generally have to limit how long the string is - the number indicates how long the string can be as a maximum.

The Wizard:
Oh I get it now.

New question = what functions do I use to remove the table?

Below is the old code, but I know that will not work.
(Sticks out thumb and hopes the Vogons wont read any potery)


--- 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 uninstall - please verify you put this in the same place as SMF\'s index.php.');

   $smcFunc['db_query']('', 'ALTER TABLE `{$db_prefix}members` DROP `shop_Dog', __FILE__, __LINE__);
   
   $smcFunc['db_query']('',"DELETE FROM `{$db_prefix}shop_items` WHERE `module` = 'Dog'", __FILE__, __LINE__);
--- End quote ---

Arantor:
Nothing.

You're installing it as part of a mod package, you should be indicating the installer file with <database> in the package-info.xml file. If you're using <database> when installing the mod package, you actually do not need to do anything, because when you uninstall the mod package it will ask you whether you want to remove data.

If you do take the choice to remove data, the package manager will do it for you.

The Wizard:
This sounds like a good idea just one problem

Here is a copy of the orginal package-info.xml file. So where and how would I add the <database> code?


--- Quote ---<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
    <id>The Wizard:myDogItem</id>
    <name>Shop Item: My Dog Image</name>
    <version>0.1</version>
    <type>modification</type>
    <install>
        <readme type="inline"><![CDATA[
This package is a new item for SMFShop which allows members to show an image of my dog next to their posts. The images are stored in Sources/shop/dog_images/.

(c) 2012 The Wizard - http://www.mywebsite.com/
Version: 0.1       

]]></readme>
        <require-file name="myDog.php" destination="$sourcedir/shop/items" />
      <require-dir name="dog_images" destination="$sourcedir/shop" />
        <modification format="xml" type="file">install.xml</modification>
        <code>installScript.php</code>
    </install>
   
   <uninstall>
      <modification type="file" reverse="true">install.xml</modification>
      <code>uninstallScript.php</code>
   </uninstall>
</package-info>
--- End quote ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version