PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 1st, 2016, 08:07 AM
mcwaloy mcwaloy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2016
Posts: 1 mcwaloy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 13 sec
Reputation Power: 0
Forms: POST & GET - Creating Database with POST API

Hi, I wrote an API to create database but when tested, it says 200 OK but doesnt create the intended database. It shows no error. Has anyone tried to or can help me show how to create database using PHP REST API POST method? I'm using slim framework. See my post code below:

`
public function post()
{
$payload = $this->request->getParsedBody();

if (!isset($payload['db_name'])) {
return $this->response((new ErrorPresenter([
'message' => 'db_nameis required'
]))->present(), 400);
}

$create = $this->container->get('db')->prepare("
CREATE DATABASE :database
");

$create->execute([
'database' => $payload['db_name']
]);
error_log('db_name= ' . $payload['db_name']);
}
`

Reply With Quote
  #2  
Old July 7th, 2017, 05:03 AM
osforum4 osforum4 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2017
Location: Germany
Posts: 1 osforum4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 52 sec
Reputation Power: 0
I can see that you create the function but didn't call it.
Have you called the function?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Forms: POST & GET - Creating Database with POST API


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap