1. Go to this page and download the library: Download dromero86/tero 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/ */
$App->get("...", function(...))
{
//data is rename of dataset
$this->data->set(...);
});
$App->get("product/:name-:id", function($name, $id)) //name unnused in the example
{
//take params
$id = (int)$id;
$this->db->query(“SELECT price FROM products WHERE product_id = {$id}”);
});
$news = new stdclass;
$news->title = “A example news”;
$news->details = “this is a example news row”;
$this->data->map(“news”, $news);
$this->view->write(“myview”, $this->data->get());
$this->data->set(“news”);
$rs = $this->db->query(“SELECT title,details FROM news_table”);
foreach($rs->result() as $row)
$this->data->map(“news”, $row);
$this->view->write(“myview”, $this->data->get());
$news = new stdclass;
$news->title = “A example news”;
$news->details = “this is a example news row”;
$this->data->automap($news, “news_”);
$this->view->write(“myview”, $this->data->get());