Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/1-create_table.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of MarPlo  >  PDO_MySQLi class  >  examples/1-create_table.php  >  Download  
File: examples/1-create_table.php
Role: Example script
Content type: text/plain
Description: Example 1
Class: PDO_MySQLi class
Access MySQL using PDO or MySQLi extensions
Author: By
Last change:
Date: 2013-09-04 02:04
Size: 695 bytes
 

Contents

Class file image Download
<?php
// includes the file that contains data for connecting to mysql database, and  PDO_MySQLi class
include('../conn_mysql.php');

// creates object with connection to MySQL
$conn = new PDO_MySQLi($mysql);

// CREATES TABLE
$sql "CREATE TABLE `testclass` (`id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, `url` VARCHAR(255), `title` VARCHAR(125), `dt` INT(11) NOT NULL) CHARACTER SET utf8 COLLATE utf8_general_ci";

// executes the SQL query, passing only the string with SQL query
$resql $conn->sqlExecute($sql);

// check if the SQL query succesfully performed, else, outputs error message
if($resql) echo 'The table "testclass" succesfully created.';
else echo 
$conn->error;