PHP code example of com.jukusoft / php-database-table-upgrader

1. Go to this page and download the library: Download com.jukusoft/php-database-table-upgrader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

com.jukusoft / php-database-table-upgrader example snippets


//create or upgrade test table
$table = new DBTable("test", $dbDriver);
$table->setEngine("InnoDB");
$table->setCharset("utf8");

//add int coloum
$table->addInt("id");

//add int coloum with length 10, NOT NULL and AUTO_INCREMENT
$table->addInt("testint", 10, true, true);

//add varchar column
$table->addVarchar("test_text", 255, true, "default value");

//add text column
$table->addText("text");

//print CREATE statement for debugging
echo $table->generateCreateQuery();

//add primary key
$table->addPrimaryKey("column_name");

//add primary key
$table->addPrimaryKey(array("id", "testint"));

//add primary key
$table->addPrimaryKey(array("id", "testint", array('column' => "test_text", 'length' => 50)));