Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Attention Developers: Gdn_DatabaseStructure->Column() method is changing.

ToddTodd Vanilla Staff
edited October 2009 in Vanilla 2.0 - 2.8
This is a message for anyone that is developing a plugin that constructs a table or adds columns to an existing table using the Column method. I am currently in the process of changing this method and I want developers to be ready when it's changed.

There is currently a method on Gdn_DatabaseStructure called Column2() which will be renamed to Column() and the original Column() will be removed. Unfortunately, I forgot to document Column2() which will be fixed, but I'll post the documentation below.

The main changes are:

1. The length parameter has been removed. Specify the length in the $Type parameters like in SQL (ex. varchar(20)).

2. Null and default have been condensed into one parameter. See the documentation below.

3. You cannot specify auto-increment columns in the Column() method anymore. Use PrimaryKey() instead.

If you want to get ready for the change then you can switch your methods over to Column2() and make sure your code works. I'll let people know when the changes get into the Dev branch on github. This will probably be Monday 12 Oct.

/**
* Defines a column to be added to $this->Table().
*
* @param string $Name The name of the column to create.
* @param mixed $Type The data type of the column to be created.
* Types with a length speecifty the length in barackets.
* If an array of values is provided, the type will be set as "enum"
* and the array will be assigned as the column's Enum property.
* @param boolean $NullDefault Whether or not nulls are allowed, if not a default can be specified.
* * TRUE: Nulls are allowed.
* * FALSE: Nullas are not allowed.
* * Any other value: Nulls are not allowed, and the specified value will be used as the default.
* @param string $KeyType What type of key is this column on the table? Options
* are primary, key, and FALSE (not a key).
*/
public function Column($Name, $Type, $NullDefault = FALSE, $KeyType = FALSE) {
...
}

Comments

Sign In or Register to comment.