Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thiagofleal/tonight-php

PHP Tonight framework
https://github.com/thiagofleal/tonight-php

Last synced: about 1 month ago
JSON representation

PHP Tonight framework

Awesome Lists containing this project

README

        

# PHP Tonight framework
Tonight-PHP is a PHP mini-framework made to easily develop SQL Database connections, MVC structures and many other tools.

## Use
To use Tonight-PHP, just install via Composer:
```shell
composer require thiagofleal/tonight-php
```

### Examples

##### Database connection

```PHP
tbl_test object) */
$database->load("tbl_test");

/* Insert row */
$database->tbl_test->insert([
'cl_test1' => "First field",
'cl_test2' => "Second field",
'cl_test3' => "Third field"
]);
$database->tbl_test->commit();

/* Get all as Table */
$all = $database->tbl_test;

/* Get all as array */
$array = $database->tbl_test->get();

/* Select rows */
$selected = $database->tbl_test->where('id', SQL::EQUAL, 10)->toArrayList();

/* Update row */
$update = $selected->first();
$update->cl_test1 = "Field 1";
$database->tbl_test->setValue($update);
$database->tbl_test->commit();

/* Delete row */
$database->tbl_test->deleteWhere('id', SQL::EQUAL, 5);
$database->tbl_test->commit();
```

#### MVC
##### Config
```PHP
setVariable("title", "Example");
$this->render("page", "template");
}

public function example($request, $args) {
$this->setVariable("value", $args->value);
$this->render("example", "template");
}
}
```