mysql

Symfony – Load Security Users from the Database – Doctrine

Caricare gli utenti attivi da un database con Symfony e Doctrine.
Il codice è solo teorico, non è pronto all’uso.
Vedere la lezione successiva ‘Symfony – Simple Registration Form – Doctrine’ per testare del codice pronto all’uso.

1. Creiamo il Database da PhpMyAdmin:

Database: test_project
Tabella: app_users
Campi:
– Id char(11) AUTO_INCREMENT
– username char (25) UNIQUE
– password char (60) UNIQUE
– email char (60) UNIQUE
– is_active BOOLEAN -> se l’utente è abilitato

2. Creiamo l’entità src/AppBundle/Entity/User.php


<?php

// src/AppBundle/Entity/User.php
namespace AppBundle\Entity;

// namespace per usare Doctrine
use Doctrine\ORM\Mapping as ORM; 
// namespace per gestire gli Utenti e ottenere le password criptate
use Symfony\Component\Security\Core\User\UserInterface;

/**
 * @ORM\Table(name="app_users")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
 */

// implements aggiunge questi metodi a UserInterface di Symfony
class User implements UserInterface, \Serializable
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=25, unique=true)
     */
    private $username;

    /**
     * @ORM\Column(type="string", length=64)
     */
    private $password;

    /**
     * @ORM\Column(type="string", length=60, unique=true)
     */
    private $email;

    /**
     * @ORM\Column(name="is_active", type="boolean")
     */
    private $isActive;

    public function __construct()
    {
        $this->isActive = true; // costruttore se l'utente è attivo
        // may not be needed, see section on salt below
        // $this->salt = md5(uniqid(null, true));
    }

    public function getUsername()
    {
        return $this->username;
    }

    // il seme o sale utilizzato per l'encode della password    
    // se uso bcrypt non è necessario perchè gestisce il seme automaticamente, e il metodo ritorna null
    public function getSalt() 
    {
        // you *may* need a real salt depending on your encoder
        // see section on salt below
        return null;
    }

    public function getPassword()
    {
        return $this->password;
    }

    public function getRoles()// i ruli concessi all'utente
    {
        return array('ROLE_USER');
    }

    public function eraseCredentials()// rimuove i dati sensibili dell'utente
    {
    }

    // Serialize
    // Alla fine di ogni - request - l'oggetto User viene trasformato in un array (serialize) e salvato nella sessione
    // Alla richiesta successiva viene ricaricato dalla sessione e riconvertito (unserialize)
    /** @see \Serializable::serialize() */
    public function serialize()
    {
        return serialize(array(
            $this->id,
            $this->username,
            $this->password,
            // see section on salt below
            // $this->salt,
        ));
    }

    /** @see \Serializable::unserialize() */
    public function unserialize($serialized)
    {
        list (
            $this->id,
            $this->username,
            $this->password,
            // see section on salt below
            // $this->salt
        ) = unserialize($serialized);
    }
}

3. Modifichiamo app/config/security.yml


# To get started with security, check out the documentation:
# http://symfony.com/doc/current/security.html

# app/config/security.yml
security:
    encoders:
        AppBundle\Entity\User:
            algorithm: bcrypt

    # http://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
    providers:
        in_memory:
            memory: ~
        test_project:
            entity:
                class: AppBundle:User
                property: username
                # if you're using multiple entity managers
                # manager_name: customer

    firewalls:
        # disables authentication for assets and the profiler, adapt it according to your needs
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        main:
            anonymous: ~
            # activate different ways to authenticate
            pattern:    ^/
            http_basic: ~
           

            # http://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate
            #http_basic: ~

            # http://symfony.com/doc/current/cookbook/security/form_login_setup.html
            #form_login: ~

Configuro i parametri di security per puntare a User.php


security:
    encoders:
        AppBundle\Entity\User:
            algorithm: bcrypt

...

test-project:
    entity:
         class: AppBundle:User
                property: username

Bibliografia:
symfony.com/doc/current/security/entity_provider.html#security-serialize-equatable
api.symfony.com/3.2/Symfony/Component/Security/Core/User/UserInterface.html#method_getRoles

By |MySQL, PHP, Symfony, Web Design|Commenti disabilitati su Symfony – Load Security Users from the Database – Doctrine

Symfony – Databases and the Doctrine ORM

Symfony non integra al suo interno componenti per lavorare con i databases, ma è integrato con la libreria di terze party ‘Doctrine’.
Possiamo trovare le librerie in Sources Files/vendor/doctrine

1. Aprire app/config/parameters.yml, questi sono i dati di accesso al DB, sono stati creati in fase di creazione del progetto


# app/config/parameters.yml

parameters:
    database_host:      localhost
    database_name:      test_project
    database_user:      root
    database_password:  

2. Aprire app/config/config.yml, qui settiamo i parametri per la corretta scrittura e charset che DEVE essere utf8mb4
utf8mb4 è stata introdotta dalla versione 5.5.3
Il vecchio utf8 usa al massimo 3 bytes, utf8mb4 usa al massimo 4 bytes per carattere, supportando quindi un maggior numero di caratteri.


doctrine:
    dbal:
        ...
        charset: utf8mb4
        default_table_options:
            charset: utf8mb4
            collate: utf8mb4_unicode_ci

3. Creiamo il DB da phpMyAdmin

Name: test_project
Codifica caratteri: utf8mb4_bin

4. Creiamola tabella: product
– Id integer auto increment
– name char lenght=100
– price decimal scale=2 (10,2)
– description text

NB: phpMyAdmin a volte non imposta correttamente 10,2 convertendolo in automatico in 10,0, in questo caso selezionare il tab SQL e digitale


ALTER TABLE `product` CHANGE `price` `price` DECIMAL(10,2) NOT NULL;

5. src/AppBundle/Entity/Product.php


<?php

// src/AppBundle/Entity/Product.php
namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="product")
 */
class Product
{
    
    // -------------------------------------------------------------------------    
    // Proprietà ---------------------------------------------------------------
    // -------------------------------------------------------------------------
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=100)
     */
    private $name;

    /**
     * @ORM\Column(type="decimal", scale=2)
     */
    private $price;

    /**
     * @ORM\Column(type="text")
     */
    private $description;
    
    // -------------------------------------------------------------------------
    // Metodi ------------------------------------------------------------------
    // -------------------------------------------------------------------------
    public function getId() // ottieni
    {
        return $this->id; // assegna il valore che proviene dall'istanza $this->
    }
 
    public function setId($id) // setta
    {
        $this->id = $id;
    }
    // -------------------------------------------------------------------------
    public function getName() // ottieni
    {
        return $this->name; // assegna il valore che proviene dall'istanza $this->
    }
 
    public function setName($name) // setta
    {
        $this->name = $name;
    }
    // -------------------------------------------------------------------------
    public function getPrice() // ottieni
    {
        return $this->price; // assegna il valore che proviene dall'istanza $this->
    }
 
    public function setPrice($price) // setta
    {
        $this->price = $price;
    }
    // -------------------------------------------------------------------------
    public function getDescription() // ottieni
    {
        return $this->description; // assegna il valore che proviene dall'istanza $this->
    }
 
    public function setDescription($description) // setta
    {
        $this->description = $description;
    }
}// end class Product

Notare che nel creare l’oggetto aggiungo le specifiche per il salvaggio nel DB con la notazione /**


use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="product")
 */

6. src/AppBundle/Controller/SaveProduct.php


<?php

// src/AppBundle/Controller/SaveProduct.php
namespace AppBundle\Controller;

use AppBundle\Entity\Product;// Product.php che ho creato io
use Symfony\Bundle\FrameworkBundle\Controller\Controller; // il bundle controller Symfont
use Symfony\Component\HttpFoundation\Response; // namespace di Symfony per response()
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;// namespace per utilizzare @Route


class SaveProduct extends Controller {
    
    /**
    * @Route("/saveproduct")
    */
    public function createAction()
    {
    // 1. Crea i prodotti
    // primo prodotto ----------------------------------------------------------    
    $product = new Product();
    $product->setName('Keyboard');
    $product->setPrice(19.99);
    $product->setDescription('Ergonomic and stylish!');
    // -------------------------------------------------------------------------
    // secondo prodotto --------------------------------------------------------
    $anotherProduct = new Product();
    $anotherProduct->setName('Mouse');
    $anotherProduct->setPrice(5.99);
    $anotherProduct->setDescription('Really cool!');
    // -------------------------------------------------------------------------
    
    // debug code --------------------------------------------------------------
    echo 'Primo Debug';
    var_dump($product); // debug notare che id = 'null', non è un problema
    // il campo Id lo gestisce Doctrine automaticamente, Id resta nel DB anche alla cancellazione del prodotto
    var_dump($anotherProduct);
    // die('Stop Here'); // debug 
    
    // 2. accesso al DB --------------------------------------------------------
    $em = $this->getDoctrine()->getManager(); // carica il metodo di Doctrin per la gestione del DB
    // 3. INSERIMENTO PRIMO OGGETTO --------------------------------------------
    // tells Doctrine you want to (eventually) save the Product (no queries yet)
    $em->persist($product); // prepara l'oggetto in Cache per velocizzarsi ma NON salva ancora
    // actually executes the queries (i.e. the INSERT query)
    $em->flush(); // metodo flush() esegue INSERT
    // 4. INSERIMENTO SECONDO OGGETTO ------------------------------------------
    $em->persist($anotherProduct);
    $em->flush();
    // 5. RIMOZIONE SECONDO OGGETTO --------------------------------------------
    $em->remove($anotherProduct);
    $em->flush();
    
    // mostra id prelevandolo dall'oggetto $product, non sta leggendo dal DB
    return new Response(
            'Saved new product with id '.$product->getId()
            );
 
    }// END createAction()
    
}// END class Saveproduct

Come funziona?

1. Istanzio per creare 2 prodotti $product = new Product(); – $anotherProduct = new Product();

2. $em = $this->getDoctrine()->getManager(); – richiamo il metodo di Doctrine per la gestione del DB

3a. $em->persist($product); – richiamo il metodo persist per creare una query temporanea in cache
3b. $em->flush(); – avvia la query INSERT

4a. $em->remove($anotherProduct); – richiamo il metodo remove per creare una query temporanea in cache
4b. $em->flush(); – avvia la query DELETE

Bibliografia:
symfony.com/doc/current/doctrine.html
docs.doctrine-project.org
docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#quoting-reserved-words

By |MySQL, PHP, Symfony, Web Design|Commenti disabilitati su Symfony – Databases and the Doctrine ORM

MySQL Quick Reference – Functions

MySQL Quick Reference – Functions

Tested on MySQL 5.5

SQL Aggregate Functions

SQL aggregate functions return a single value, calculated from values in a column.


/* SELECT AVG(column_name) FROM table_name */
SELECT AVG(column_name) FROM table_name

/* The COUNT() function returns the number of rows that matches a specified criteria */
SELECT COUNT(column_name) FROM table_name;

/* The COUNT(*) function returns the number of records in a table */
SELECT COUNT(*) FROM table_name;

/* The COUNT(DISTINCT column_name) function returns the number of distinct values of the specified column */
SELECT COUNT(DISTINCT column_name) FROM table_name;

/* The FIRST() function returns the first value of the selected column */
/* MySQL not support FIRST() but you can use: */
SELECT column_name FROM table_name
ORDER BY column_name ASC
LIMIT 1;

/* The LAST() function returns the first value of the selected column */
/* MySQL not support LAST() but you can use: */
SELECT column_name FROM table_name
ORDER BY column_name DESC
LIMIT 1;

/* The MAX() function returns the largest value of the selected column */
SELECT MAX(column_name) FROM table_name;

/* The MIN() function returns the smallest value of the selected column */
SELECT MIN(column_name) FROM table_name;

/* The SUM() function returns the total sum of a numeric column */
SELECT SUM(column_name) FROM table_name;

/* The GROUP BY statement is used in conjunction with the aggregate functions to group the result-set by one or more columns */
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name;

/* The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions */
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value;

SQL Scalar functions

SQL scalar functions return a single value, based on the input value.


/* The UCASE() function converts the value of a field to uppercase */
SELECT UCASE(column_name) FROM table_name;

/* The LCASE() function converts the value of a field to lowercase */
SELECT LCASE(column_name) FROM table_name;

/* The MID() function is used to extract characters from a text field */
SELECT MID(column_name,start[,length]) AS some_name FROM table_name;

/* The LEN() function returns the length of the value in a text field */
SELECT LEN(column_name) FROM table_name;

/* The FORMAT() function is used to format how a field is to be displayed */
SELECT FORMAT(column_name,format) FROM table_name;

By |MySQL, Web Design|Commenti disabilitati su MySQL Quick Reference – Functions

MySQL Quick Reference – Dates

MySQL Quick Reference – Dates

Tested on MySQL 5.5

Date Data Types

DATE – format YYYY-MM-DD
DATETIME – format: YYYY-MM-DD HH:MM:SS
TIMESTAMP – format: YYYY-MM-DD HH:MM:SS
YEAR – format YYYY or YY

Date Functions

NOW() Returns the current date and time
CURDATE() Returns the current date
CURTIME() Returns the current time

DATE() Extracts the date part of a date or date/time expression
EXTRACT() Returns a single part of a date/time
DATE_ADD() Adds a specified time interval to a date
DATE_SUB() Subtracts a specified time interval from a date
DATEDIFF() Returns the number of days between two dates
DATE_FORMAT() Displays date/time data in different formats

Syntax Examples:


/* Example ######################### */

CREATE TABLE Orders
(
... you want to do ...

OrderDate datetime NOT NULL DEFAULT NOW(),

OrderDate datetime NOT NULL DEFAULT CURDATE(),

OrderDate datetime NOT NULL DEFAULT CURTIME(),

... you want to do ...
)

/* Example ######################### */

SELECT ProductName, DATE(OrderDate) AS OrderDate
FROM Orders
WHERE OrderId=1

/* Example ######################### */

SELECT EXTRACT(YEAR FROM OrderDate) AS OrderYear,
EXTRACT(MONTH FROM OrderDate) AS OrderMonth,
EXTRACT(DAY FROM OrderDate) AS OrderDay,
FROM Orders
WHERE OrderId=1

/* Example ######################### */
/* Now we want to add 45 days to the "OrderDate", to find the payment date */

SELECT OrderId,DATE_ADD(OrderDate,INTERVAL 45 DAY) AS OrderPayDate
FROM Orders

/* Example ######################### */
/* Now we want to subtract 5 days from the "OrderDate" date. */

SELECT OrderId,DATE_SUB(OrderDate,INTERVAL 5 DAY) AS SubtractDate
FROM Orders

/* Example ######################### */
/* The result is -1 */

SELECT DATEDIFF('2008-11-29','2008-11-30') AS DiffDate

/* Example ######################### */

DATE_FORMAT(NOW(),'%b %d %Y %h:%i %p')
DATE_FORMAT(NOW(),'%m-%d-%Y')
DATE_FORMAT(NOW(),'%d %b %y')
DATE_FORMAT(NOW(),'%d %b %Y %T:%f')

/* The Result:

Nov 04 2008 11:45 PM
11-04-2008
04 Nov 08
04 Nov 2008 11:45:34:243 */

By |MySQL, Web Design|Commenti disabilitati su MySQL Quick Reference – Dates

MySQL Quick Reference – Basic

MySQL Quick Reference – Basic

Tested on MySQL 5.5

Syntax

1. Open phpMyAdmin and select a database
2. TOP MENU> localhost> lucedigi_test
3. TOP LABELS> SQL
4. BOTTOM MENU ‘SELECT*’ button

Input:

SELECT * FROM `Persons`;

– SQL ARE NOT CASE SENSITIVE
– USE SEMICOLON ‘;’ to to separate each SQL statement
– `Persons` is not ‘Persons’ -> ` is dfifferent of ‘

FROM MySQL to PHP MYSQL

1. Open phpMyAdmin and select a database
2. TOP MENU> localhost> lucedigi_test
3. TOP LABELS> SQL
4. Input your code
5. BOTTOM RIGHT ‘Esegui’ Button
6. In the next window on the right [Crea codice PHP]

SELECT

Table name: Persons
Columns: PID, First Name, Last Name, Age.


/* Comments */ 

/* Select All */ 
SELECT * FROM `Persons`;

/* Select only specified columns */ 
SELECT `PID`, `FirstName`, `LastName`, `Age` FROM `Persons`;

/* In a table, a column may contain many duplicate values; and sometimes you only want to list the different (distinct) values. */ 
SELECT DISTINCT `FirstName`, `LastName`
FROM Persons;

SELECT … WHERE


/* The WHERE clause is used to extract only those records that fulfill a specified criterion. */ 
/* Operators = <> > < >= <= BETWEEN LIKE IN */ 
SELECT * FROM Persons
WHERE FirstName='Erica';

/* Operators for multiple values START */ 
/* ################################### */

SELECT * FROM Persons
WHERE FirstName='Erica'
AND LastName='Tonin';

SELECT * FROM Persons
WHERE FirstName='Erica'
OR LastName='Tonin';

SELECT * FROM Persons
WHERE FirstName='Erica'
AND (LastName='Tonin' OR LastName='Santato');

SELECT * FROM Customers
WHERE City IN ('Paris','London');

SELECT * FROM Products
WHERE Price NOT BETWEEN 10 AND 20;

SELECT * FROM Products
WHERE (Price BETWEEN 10 AND 20)
AND NOT CategoryID IN (1,2,3);

SELECT * FROM Products
WHERE ProductName BETWEEN 'C' AND 'M';

SELECT * FROM Products
WHERE ProductName NOT BETWEEN 'C' AND 'M';

SELECT * FROM Orders
WHERE OrderDate BETWEEN #07/04/1996# AND #07/09/1996#;

/* ################################### */
/* Operators for multiple values END */ 

ORDER


/* The ORDER BY keyword is used to sort the result-set */ 
/* Default is ASC - ascending */ 
SELECT * FROM Persons
ORDER BY LastName; 

/* DESC - descending */
SELECT * FROM Persons
ORDER BY LastName DESC;

/* In ordine avremo Erica Santato poi Erica Tonin - a parità di FirstName si classifica con il LastName */
SELECT * FROM Persons
ORDER BY FirstName,LastName;

INSERT – UPDATE


/* Insert New Records in a table */ 
INSERT INTO Persons (FirstName, LastName)
VALUES ('Ivan', 'Danko');

/* Update records in a table */ 
/* ATTENZIONE!!!!  Se si omette WHERE tutti i record saranno sovrascritti! */ 
UPDATE Persons
SET FirstName='Sylvester', LastName='Stallone'
WHERE FirstName='Ivan';

DELETE


/* Delete records */ 
/* ATTENZIONE!!!!  Se si omette WHERE tutti i record saranno cancellati! */ 
DELETE FROM Persons
WHERE FirstName='Sylvester' AND LastName='Stallone';

/* Delete ALL DATA */
DELETE FROM Persons;

LIMIT


/* LIMIT Specifies the number of records to return */
SELECT LastName
FROM Persons
LIMIT 3;

Wildcards

A wildcard character can be used to substitute for any other character(s) in a string.


/* LIKE searches for a specified pattern in a column */
/* The Result is Tonin - Zonin - Ponin - Conin etc... */
SELECT * FROM Persons
WHERE LastName LIKE '%oni%';

/* The Result is Tonin - Tonib - Toniv - Tonis etc... */
SELECT * FROM Persons
WHERE LastName LIKE 'Toni%';

/* The following SQL statement selects all customers with a City 
starting with any character, followed by "erlin": */
SELECT * FROM Customers
WHERE City LIKE '_erlin';

/* The following SQL statement selects all customers with a City starting with "L", 
followed by any character, followed by "n", followed by any character, followed by "on" */
SELECT * FROM Customers
WHERE City LIKE 'L_n_on';

/*The following SQL statement selects all customers with a City starting with "b", "s", or "p":*/
SELECT * FROM Customers
WHERE City LIKE '[bsp]%';

/*The following SQL statement selects all customers with a City starting with "a", "b", or "c":*/
SELECT * FROM Customers
WHERE City LIKE '[a-c]%';

/*The following SQL statement selects all customers with a City NOT starting with "b", "s", or "p":*/
SELECT * FROM Customers
WHERE City LIKE '[!bsp]%';

INNER JOINT

SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers
ON Orders.CustomerID=Customers.CustomerID;

Il render sarà:

1.Tabella Orders -> OrderID
2.Tabella Customers -> CustomerName -> al verificarsi della condizione -> Orders.CustomerID=Customers.CustomerID
3.Tabella -> OrderDate

UNION

/* UNION operator combines the result of two or more SELECT statements 
(only distinct values) */
SELECT City FROM Customers
UNION
SELECT City FROM Suppliers
ORDER BY City;

/* UNION ALL operator combines the result of two or more SELECT statements 
(duplicate values also) */
SELECT City FROM Customers
UNION ALL
SELECT City FROM Suppliers
ORDER BY City;

/* With WHERE */
SELECT City, Country FROM Customers
WHERE Country='Germany'
UNION ALL
SELECT City, Country FROM Suppliers
WHERE Country='Germany'
ORDER BY City;

SELECT INTO – INSERT INTO (create a copy)

The SELECT INTO statement copies data from one table and inserts it into a new table.

MySQL does not support SELECT INTO statement!!!

You can fix the problem:


/* Create a new table, with same structure, where you want to take backup */
CREATE TABLE destination_table_name LIKE source_table_name;

/* After then you can use this command to copy those data */
INSERT INTO destination_table_name 
SELECT * FROM source_table_name;

/* If you already have previous data in your Destination table , Firstly you can use this command */
TRUNCATE TABLE destination_table_name;

/* Copy only the columns FirstName, LastName */
INSERT INTO PersonsBackUp (FirstName, LastName)
SELECT FirstName, LastName FROM Persons;

CREATE DB

NOTICE: if you work with shared hosting services, the best way is CPanel Admin to create new Databases

CREATE DATABASE dbname;

CREATE TABLE

phpMyAdmin> LEFT COLUMN> ‘Crea tabella’

or


CREATE TABLE Persons
(
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);

INDEX

Indexes allow the database application to find data fast; without reading the whole table.

Note: Updating a table with indexes takes more time than updating a table without (because the indexes also need an update). So you should only create indexes on columns (and tables) that will be frequently searched against.


CREATE INDEX PIndex
ON Persons (LastName)

CREATE INDEX PIndex
ON Persons (LastName, FirstName)

DROP

It removes indexes, tables, and databases


/* Delete index */
ALTER TABLE table_name DROP INDEX index_name

/* Delete table */
DROP TABLE table_name

/* Delete database */
DROP DATABASE database_name

/* Delete table content only, preserve table */
TRUNCATE TABLE table_name

ALTER

The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.

Statement:
ALTER TABLE table_name
MODIFY COLUMN column_name datatype


ALTER TABLE Persons
ALTER COLUMN DateOfBirth year

ALTER TABLE Persons
DROP COLUMN DateOfBirth

AUTO INCREMENT

Very often we would like the value of the primary key field to be created automatically every time a new record is inserted.

By default, the starting value for AUTO_INCREMENT is 1, and it will increment by 1 for each new record.


CREATE TABLE Persons
(
ID int NOT NULL AUTO_INCREMENT,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
PRIMARY KEY (ID)
)

/* Let the AUTO_INCREMENT sequence start with another value */
ALTER TABLE Persons AUTO_INCREMENT=100

By |MySQL, Web Design|Commenti disabilitati su MySQL Quick Reference – Basic