Jump to: navigation, search

PHP ADODB Create Table

From w3cyberlearnings

Contents

PHP ADODB Create A Table

Create a table use Execute method.

Syntax ADODB

$sql = "CREATE TABLE IF NOT EXISTS user_infor (
   id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
	first_name VARCHAR(200) NOT NULL,
	last_name VARCHAR(200) NOT NULL,
	email VARCHAR(200) NOT NULL	
)";

$result = $conn1->Execute($sql);

Example 1

<?php

include 'adodb5/adodb.inc.php';

$host = 'localhost';
$user = 'user2000';
$pass = 'password2000';
$dbname = 'w3cyberlearning';

$conn1 = &ADONewConnection('mysql');
$conn1->PConnect($host, $user, $pass, $dbname);

$sql = "CREATE TABLE IF NOT EXISTS user_infor (
   id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
	first_name VARCHAR(200) NOT NULL,
	last_name VARCHAR(200) NOT NULL,
	email VARCHAR(200) NOT NULL	
)";

$result = $conn1->Execute($sql);

if ($result == false) {
	print 'error' . $conn1->ErrorMsg() . '<br>';
}
else {
	echo 'create';
}


?>

Output

create


Related Links


Navigation
Web
SQL
MISC
References