Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-18-2004, 01:44 AM
Warlord's Avatar
Warlord Warlord is offline
 
Join Date: Jan 2002
Location: TN, USA
Posts: 668
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Attempting to create my first hack from scratch...

I requested a hack in the requests forum and then thought I'd try to make it myself I went to a site to learn a little about mysql, but I have a question for anyone that can answer.

I took their mysql commands:

PHP Code:
CREATE TABLE employees (  id tinyint(4) DEFAULT '0' NOT NULL AUTO_INCREMENT,  first varchar(20),  last varchar(20),  address varchar(255),  position varchar(50),  PRIMARY KEY (id),  UNIQUE id (id));INSERT INTO employees VALUES (1,'Bob','Smith','128 Here St, Cityname','Marketing Manager'); 
And edited them to reflect more of what I think I want my table to look like:

PHP Code:
CREATE TABLE bios (  id tinyint(4) DEFAULT '0' NOT NULL AUTO_INCREMENT,  name varchar(30),  secretidentity varchar(50),  groupaffiliation varchar(255),  height varchar(10),  weight varchar(10), haircolor varchar(20),  eyecolor varchar(20),  powers varchar(255), history varchar(255),  PRIMARY KEY (id),  UNIQUE id (id)); 
Now, I think I've figured out what most of these commands do, and what they stand for but a few I'm not to sure about, and I'd rather know what they all do then copy and paste them (I remember them better when I understand their function)

create table obviously creates the table (duh)

I assume the ( after bios lets phpMyAdmin know that the columns are about to follow?

What does id tinyint(4) DEFAULT '0' NOT NULL do? Is this one long command or 3? (Looks like three to me)

AUTO_INCREMENT sounds like it's telling phpMyAdmin that you want it to count and assign each row of data a number sequentially (1, 2, 3, etc) Yes?

varchar is obviously the character limit.. but what does var stand for? And why is the max limit only 255? How do you get around this max limit? phpMyAdmin said to use BLOB instead, but how do I use that?

What does PRIMARY KEY (id) do?

What does UNIQUE id (id) do?

The last) seems to be some sort of closing tag letting the server know it's done inserting columns. And I would guess the ; is to let the server know that the entire command is done?

Any help you all can provide is appreciated. After I have the answers to these questions, I will likely have more, so thanks in advance for you patience with me.

-WL
Reply With Quote
  #2  
Old 09-18-2004, 06:36 AM
Colin F's Avatar
Colin F Colin F is offline
 
Join Date: Jul 2004
Location: Switzerland
Posts: 1,551
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

As you correctly interpreted, you are setting the columns in the ()'s
id... is one long command.

"id" is the name of the column
"tinyint" is the columntype (different types let you enter different types of data, some let you enter numbers (anything with *int), some let you enter text or text mixed with numbers, and so on)
(4) is the maximum length of the data entered in this column
DEFAULT'0' tells it to set this column to '0' if no data is entered (will be overriden by auto_increment)
auto_increment means it will assign a number automatically, starting with 1 and just always counting one up.
PRIMARY KEY and UNIQUE ID are indexes, which allow faster searching of the table, if only one of these values are searched for., UNIQUE ID additionally tells it that every entry into that column is unique

I missed some things, but maybe it helped you a bit. I'll try explain the rest when I have a bit more time.
Reply With Quote
  #3  
Old 09-18-2004, 04:49 PM
Warlord's Avatar
Warlord Warlord is offline
 
Join Date: Jan 2002
Location: TN, USA
Posts: 668
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for taking your time to help explain some of those things to me.
Reply With Quote
  #4  
Old 09-24-2004, 06:54 PM
Warlord's Avatar
Warlord Warlord is offline
 
Join Date: Jan 2002
Location: TN, USA
Posts: 668
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So, how do I get around the 255 character limit?
Reply With Quote
  #5  
Old 09-24-2004, 07:13 PM
nexialys
Guest
 
Posts: n/a
Default

*varchar are limites to 255 characters wide - to have a larger set, use char(xxx) (or use mediumtext,text with larger bank)... btw, i think you'd be better read the entire documentation at mysql.com so you have a good overview on how to manage mysql queries...

http://dev.mysql.com/doc/mysql/en/index.html
Reply With Quote
  #6  
Old 09-24-2004, 10:27 PM
Warlord's Avatar
Warlord Warlord is offline
 
Join Date: Jan 2002
Location: TN, USA
Posts: 668
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the quick reply nex, but I tried it and it seems char has the same 255 max character limit that varchar does. It instructed me to use BLOB, which I figured out how to do (it wasn't hard, just had to find where to change it, lol) but then there's nowhere to insert anything into that field, because it says "BINARY - Do not edit" instead of having a text input field.

I'll check that link out too, thanks for that. I'm gonna look up all of these type settings and see what I can dig up.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:05 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06123 seconds
  • Memory Usage 2,213KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (5)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete