File: documentation/parser.php

Recommend this page to a friend!
  Classes of Mihajlo Siljanoski  >  ApiQL.net PHP SQL API Builder  >  documentation/parser.php  >  Download  
File: documentation/parser.php
Role: Example script
Content type: text/plain
Description: Example script
Class: ApiQL.net PHP SQL API Builder
Serve an API to query certain SQL database tables
Author: By
Last change:
Date: 4 months ago
Size: 807 bytes
 

 

Contents

Class file image Download
<?php
require_once '../config/config.php';
require_once
'../src/Apiql.php';
$ApiQL = new Apiql($config);

$tables = $ApiQL->db->list_tables();

$endpoints = [];

foreach(
$tables as $table){
   
$fieldsData = $ApiQL->db->query("SHOW FIELDS FROM ".$table)->result_array();
    if(
in_array($table, array_keys($config['allowed_actions']))){
       
$endpoints[$table] = $fieldsData;
    }
}

$postdata = http_build_query(
    array(
       
'config' => $config,
       
'endpoints' => $endpoints
   
)
);

$opts = array('http' =>
    array(
       
'method' => 'POST',
       
'header' => 'Content-Type: application/x-www-form-urlencoded',
       
'content' => $postdata
   
)
);

$context = stream_context_create($opts);

echo
file_get_contents('https://apiql.net/documentation/build.php', false, $context);


For more information send a message to info at phpclasses dot org.