Coder Social home page Coder Social logo

php-sp-api's Introduction

PHP-SP-API

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.

Requirements

  • PHP 5.3 or higher

php-sp-api's People

Contributors

cherianmpaul avatar mevdschee avatar mvdriel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-sp-api's Issues

SP Questions

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

Packets out of order

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?

https://stackoverflow.com/questions/19389809/packets-out-of-order-error-when-calling-mysql-stored-proc/30275001

MSSQL

Does this work with MSSQL Databases?

Stored Procedures with Parameters

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);
}

Handling Errors?

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?

500 Internal Server Error

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.

How to create api request using POSTMAN

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.

call a stored proc

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.