PHP Classes

File: create-tables.php

Recommend this page to a friend!
  Classes of Ahmad Mustapha   Simple React PHP CRUD   create-tables.php   Download  
File: create-tables.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simple React PHP CRUD
Manipulate records in a page done using ReactPHP
Author: By
Last change:
Date: 3 years ago
Size: 688 bytes
 

Contents

Class file image Download
<?php
date_default_timezone_set
('America/Sao_Paulo');
error_reporting(E_ALL);

use
Crud\User;
use
React\EventLoop\Factory;

require
'vendor/autoload.php';

$loop = Factory::create();

$conn = (new User($loop))->getConnection();

$conn->query('
    CREATE TABLE IF NOT EXISTS users(
        id INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
        username VARCHAR(200) NOT NULL ,
        userCode VARCHAR(100) NOT NULL ,
        time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)
    );
'
)->then(
    function () use (
$conn){
       
var_dump('Database table created');
       
$conn->close();
    },
    function (
Throwable $exception) {
        echo
$exception;
    }
);

$loop->run();