PHP Classes

File: create-table.php

Recommend this page to a friend!
  Packages of Gjero Krsteski   PHP Nuclear Reactor   create-table.php   Download  
File: create-table.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Nuclear Reactor
Asynchronous RESTful API using ReactPHP and PIMF
Author: By
Last change: Update of create-table.php
Date: 7 years ago
Size: 654 bytes
 

 

Contents

Class file image Download
<?php
require_once 'vendor/autoload.php';
include_once 'app/bootstrap.app.php';

Pimf\Config::load($config);

$em =  new Pimf\EntityManager(
    Pimf\Pdo\Factory::get(Pimf\Config::get(Pimf\Config::get('environment') . '.db')),
    Pimf\Config::get('app.name')
);

try {

    $pdo = $em->getPDO();

    $res = $pdo->exec(
        file_get_contents(
            BASE_PATH . 'app/Articles/_database/create-table.sql'
        )
    ) or print_r($pdo->errorInfo(), true);

    echo $res === false
        ? 'PROBLEMS CREATING TABLE!'
        : 'TABLE SUCCESSFULLY RECREATED';

} catch (\PDOException $e) {
    throw new \RuntimeException($e->getMessage());
}