PHP Classes

File: logic/installLogic.php

Recommend this page to a friend!
  Classes of Faris AL-Otabi   PHP URL Shortener   logic/installLogic.php   Download  
File: logic/installLogic.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP URL Shortener
Application to create and expand short URLs
Author: By
Last change:
Date: 11 months ago
Size: 1,147 bytes
 

Contents

Class file image Download
<?php

$db
= new Framework\Database();

$utils = new Framework\Utils();

$install = new Framework\Migration($db, $utils);

if (
$_SERVER['REQUEST_METHOD'] == 'POST') {
   
$install->createTable(
       
'short_urls',
        [
            [
'id', 'INT(11)', 'UNSIGNED', 'NOT NULL'],
            [
'long_url', 'VARCHAR(225)', 'NOT NULL'],
            [
'short_code', 'VARCHAR(27)', 'NOT NULL'],
            [
'password', 'VARCHAR(225)', 'NULL', 'DEFAULT NULL'],
            [
'hits', 'INT(11)', 'NOT NULL', 'DEFAULT 0'],
            [
'created', 'TIMESTAMP', 'NOT NULL', 'DEFAULT CURRENT_TIMESTAMP']
        ]
    );

   
$install->isPrimary("short_urls", "id");

   
$install->isAutoinc("short_urls", ['id', 'INT(11)', 'UNSIGNED', 'NOT NULL']);
   
   
// Enable Production Mode
    /* -------------------------- */
   
$env_file = APP_PATH . "config/environment.php";

   
$env_file_content = file_get_contents($env_file);

   
$env_file_content = preg_replace("/installation/", "production", $env_file_content, 1);

   
file_put_contents($env_file, $env_file_content);
   
/* -------------------------- */

   
$msg = "Software has been installed";
}