Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > Terms in PHP
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 28th February 08:46
netsurfer802
External User
 
Posts: 1
Default "Terms" in PHP



Hi:

I'm somewhat knew in programming with PHP and have tried referencing
the http://www.php.net website to find out what certain sections or "terms" of
code mean, or what significance they have..and perhaps that don't have
much.

I'm currently reading about creating a query for a MySQL table in PHP.

For the script reading:

$query = 'CREATE TABLE blog_entries (
blog_id INT UNASIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(100) NOT NULL, entry TEXT NOT NULL,
date_entered DATETIME NOT NULL
)';

Now, is there an actual definition for the "_id" part of "blog_id" or
is that just part of the name of the column of this table? (According
to the book I'm reading it is the first column but was wondering if
there was more significance behind the "_id" part...(if it means
something in PHP.)

Also, it mentions it's an unassigned integer, and that because of this
it has to be a positive whole number. Why does it have to be a
positive whole number?

Also, does VARCHAR(100) mean a variable limited to 100 characters?

Thanks very much in advanced for any feedback.
  Reply With Quote


  sponsored links


2 28th February 08:46
zeldorblat
External User
 
Posts: 1
Default "Terms" in PHP



Just part of the column name...nothing to do with PHP. How you name
the columns in the database is up to you. People tend to name their
primary key columns that way, although there are a lot of alternatives:

*_id
*_Id
*_ID
*ID
*Key
etc...

Do you mean *unsigned* integer?

integer = whole number between negative infinity and infinity
unsigned = has no sign, hence is positve
unsigned integer = whole number that is positve (including zero)

Most database systems (well, probably all) offer different datatypes
for storing different types of data. Depending on what you're storing,
they take up different amounts of space. So you typically choose a
type that:

a) stores the type data you want (integer, numeric, string, binary,
etc.)
b) is of an appropriate size

If a particular column only needs to have positive integers, then use
the unsigned integer type (or equivalent). In this way you don't waste
the space that you would otherwise need if you were storing say,
decimal values.

Strings work the same way. varchar(100) and char(100) can contain up
to 100 characters. As far as I know the main difference is that
varchar has a small overhead to store the length of the string that's
currently there, but it only stores the data you put in it. char(100)
will store a single character as a 100 character string. So if the
strings are short or all about the same length, use char, otherwise use
varchar.

I suppose I should reiterate that all of this really has more to do
with the database you're using than PHP.
  Reply With Quote
3 28th February 08:46
netsurfer802
External User
 
Posts: 1
Default "Terms" in PHP


Yes it did say "unsigned"...thanks very much for your response and this
clears up a lot.

I guess my only question is on the difference between char(100) and
varchar(100)...does the "var" part mean it's a variable?

MC
  Reply With Quote
4 28th February 08:46
zeldorblat
External User
 
Posts: 1
Default "Terms" in PHP


I'll quote myself:
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666