Results 1 to 4 of 4

Thread: PHP - Database and PHPMyAdmin

  1. #1
    Join Date
    Jul 2010
    Posts
    75

    PHP - Database and PHPMyAdmin

    The databases are very important elements in PHP. They are used to store data. Their big advantage is that using a dedicated language, we will be able to retrieve stored data quickly, making many operations on it, all in record time. One often abbreviates "database" with BDD, so if you see me write it later, do not ask questions is called a DBMS management system database. The advantage is that the DBMS to fetch your data, you do not worry about where data is stored or how you say "I want such data" and the DBMS to fetch it for you. You can also retrieve data from a very complicated manner that depends by many factors, something almost impossible by storing data in a file without computationally very heavy. The language is used to query and perform operations on one or more databases / tables called SQL. For what follows, we will use a DBMS called MySQL. This is the most common SQBD, so you should have no problem to run your site later. However, PHP supports other DBMS Here is a partial list:

    • mSQL
    • Sybase
    • MySQL
    • Oracle
    • Unix dbm
    • Informix
    • SQL Server
    • PostgreSQL.

  2. #2
    Join Date
    Jul 2010
    Posts
    75

    Re: PHP - Database and PHPMyAdmin

    Tables

    A database contains tables. An analogy: You have an office that represents the database. In this office you have records, these are the tables. These files contain records for us the data. A table contains fields. Each field will be able to receive a data type specific. We do not store a social security number with the same type as the first and last name. Here we have three fields:
    • id_cat: it is a number used to distinguish all categories. Later, we see that it is also a question of optimization. It does not use the "name" field to distinguish the categories, but a number field, which will be much faster to process for MySQL.
    • Name: This is a category name
    • Description: This is a description of our class
    Each of the data you store in the table will fill the fields, and is given by a table row. For example to store items you could have a list of fields like "number, title, text" the whole forming the table "items". It is important to know that a table can have an infinite number of data (within the limits of your hardware resources of course). A database can also contain an infinite number of tables.

  3. #3
    Join Date
    Jul 2010
    Posts
    75

    Re: PHP - Database and PHPMyAdmin

    PHPMyAdmin

    PHPMyAdmin is a PHP application that allows you to manage your databases. You will be able to create databases, tables, etc. ... without worrying about the SQL language to write it. To access PHPMyAdmin, type in your browser the following address:

    If you installed EasyPHP, type this: http://localhost/mysql/ (the / end is important). Get ready to create your database. For example, we will create a database called news. So put news in the Create a database and click Create. Do not worry about the collation field. The database was created. As you can see, the SQL language that was used PHPMyAdmin to create this database is CREATE DATABASE news.

    This is what we call an application (My) SQL. We will now create a table that will contain news on our news website. Now consider the number of fields that we could make. First, we need to identify each of the news posted. I told you earlier that it had to use a numeric field. We will appoint id_news. Each news will have a different id. Then we must know the title of the news, date of publication, the author of the news and its text. We then have 5 fields in total. In the name box, type news in box number field, enter 5, and then click Run. You are now presented with a list of fields that will have to be determined. The first field will be our field id_news. Indicate so in the first box id_news. For the type of field, I let you watch this page: MySQL field types. Upon reflection, you can have a sizeable amount of news, so we will use a type with the attribute UNSIGNED SMALLINT. So you can store 65,536 news. I think it's okay right?

  4. #4
    Join Date
    Jul 2010
    Posts
    75

    Re: PHP - Database and PHPMyAdmin

    In the extra field indicate autoincrement. Why? because in fact, the advantage of this type of field you will be able not to worry about the number to add, MySQL will do it for you. When you add a news item, you will not have to go retrieve the maximum number entered for him and add an insert into the database. Then select the third option (the icon with a U), indicating that this field is a field with a unique value (this is also an index that will allow you to accelerate research on the base, but we come later). For the second field, it is the title of the news. We can name the title field, and put a VARCHAR (put 255 in the size / value). For the third field, this is a release date. You know what a timestamp, we will not use this type of field because the timestamp of PHP and MySQL that are different. However, we will use a type INT UNSIGNED attribute, which will store dates from the time () function of PHP.

    For the fourth field, we will use the author name, containing the nick of the poster's news with the type VARCHAR and 20 characters in the size / value. You should know that it would be more efficient to store a number corresponding to a membership number, only we do not have table members and I'm not going to complicate your task for this first year. The final field will be of type TEXT and will be known as text. It used to contain the text of the news. Choose in the "storage engine" option MyISAM. I do not say why, but be aware that some types of tables are not supported with some hosts, this is not the case of MyISAM. This is not dramatic in itself because you can change the table type options via PHPMyAdmin, but other types offer certain features that we will not detail here and can not be adapted. Once everything is completed, click the Save button. If all goes well, PHPMyAdmin execute the following query:
    Code:
    CREATE TABLE `news` ( 
    `` Id_news MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT, 
    `Title` VARCHAR (255) NOT NULL, 
    `Date` INT UNSIGNED NOT NULL, 
    `Author` VARCHAR (20) NOT NULL, 
    `Text` TEXT NOT NULL, UNIQUE (`id_news`)) 
    ENGINE = MyISAM;
    After this I am sure that you people will be able to do your own.

Similar Threads

  1. How do I enable InnoDB storage in phpmyadmin?
    By s10gah in forum Networking & Security
    Replies: 3
    Last Post: 29-10-2010, 03:05 AM
  2. enable innodb using phpmyadmin
    By Tomthegreat in forum Networking & Security
    Replies: 3
    Last Post: 20-05-2009, 01:19 PM
  3. How to Export the database in phpMyAdmin
    By Nurhan in forum Software Development
    Replies: 2
    Last Post: 24-02-2009, 01:53 PM
  4. phpMyAdmin 3.1.0 beta1 is released
    By DllD in forum Windows Software
    Replies: 0
    Last Post: 10-11-2008, 02:40 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,516,480.66829 seconds with 17 queries