Single file PHP script that adds a REST API to a SQL database
This project reflects the database and creates an API endpoint for each defined stored procedure.
- PHP 5.3 or higher
Single file PHP script that adds a REST API to a SQL database
how do you intend for this file to be used? it looks stand alone. Can you provide more information maybe in the readme?
Hi, I've two questions:
1- The API supports stored procedures with parameters?. If yes, how to do it?
2- What's the security of the api? Can I use auth / https / etc ? Or anyone person that uses POST in the url can view the info?
Thanks
Getting a repeatable error on calling a stored proc:
Warning: Packets out of order. Expected 15 received 1. Packet size=7 in /home/xxx/api.php on line 128
Warning: mysqli_next_result(): MySQL server has gone away in /home/xxxx/api.php on line 128
Warning: mysqli_next_result(): Error reading result set's header in /home/xxxx/api.php on line 128
I can repeatedly call the same stored proc without issue in a remote dbForge MySQL session so I know the proc is fully functional. The stored proc is creating a statement that is then executed - I think likely related.
Even though I have DEALLOCATE PREPARE stmt;
the error is occurring when I make the same call again with the same resulting stmt call. If that call is different, I don't get the error.
Looks like this is the issue, although this references PDO - can you help with a fix?
Does this work with MSSQL Databases?
Hi,
I have a stored Procedure with parameters. Can you give me a hint, how the url or my php code have to look? My current code looks like shown in the screenshot down below.
function getModell($herstellerID) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://aw96.de/api.php/getModell",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache"
),
));
return $response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
}
I have some stored procedures that will generate errors using the syntax
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = '[My error message here]';
Could the API be adjusted to make these error messages available?
Dear Maurits,
I tested the API on my 'localhost' server. It worked perfectly!
When running on my web server I get the following error:
'500 Internal Server Error'
I did some testings.
I've the impression that following code causes the error:
$values = array_map(function ($value) use ($link) { if ($value===null) return null; return mysqli_real_escape_string($link,(string)$value); },array_values($input));
Dou you have any idea what's going wrong?
Thanks for your advise.
Hi! i'd like to know the difference between this library and php-crud-api ?
I am trying to figure out how to use this api with postman, however I cannot figure out what the parameter names would be. or how to pass the parameters to the server.
Hi
I'm trying to find my first steps in php_crud, which is quite self explenatory.
I was also trying this php-sp-api which I could not understand how to use it.
I will appreciate any explanation,
Regards and thanks
Eli
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.