php - 使用 php 框架 silex 更新行

标签 php mysql angularjs api silex

我正在制作一个 Angular 应用程序,对于后端,我使用 symphony 的微框架创建一个 REST API:silex

在某个更新中,我不断收到内部服务器错误。我所做的就是更新权重。

$app->put('/{id}/updateWeight', function ($id) use ($app) {

  $sql = "UPDATE results SET weight=20 WHERE usersId = $id";
  $test = $app['db']->executeUpdate($sql, array((int) $id));

  return $test;

});

最佳答案

感谢大家的回复,在我想发布错误之前,我又仔细查看了错误,发现了问题。

我认为错误是在我上面发布的代码段中创建的,但实际上这条路线似乎与另一条路线混淆了,即这条路线:

$app->put('/{name}/{goalsId}', function ($name, $goalsId) use ($app) {

$sql = "UPDATE users SET goalsId=".$goalsId." WHERE username ='".$name."' ";
$users = $app['db']->executeUpdate($sql, array($goalsId, (int) $name));
//$user = $app['db']->fetchAssoc($sql, array((string) $username));
return $goalsId;

});

这显然造成了错误。

更改路线

$http.put("../api/web/"+user.usersId+"/updateWeight/")

$http.put("../api/web/updateweight/"+user.usersId)

成功了。

关于php - 使用 php 框架 silex 更新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30264430/

相关文章:

mysql - 如何从mysql表中获取最后一条记录和倒数第二条记录

mysql - Prestashop - ListView 过滤器

MYSQL:在 CONCAT() 函数中使用列名给出语法错误 1064

javascript - 错误 : Argument 'HomeCtrl' is not a function, 未定义

PHP 服务 MP4 - Chrome "Provisional headers are shown/request is not finished yet"错误

php:非对象错误 - 数组输出到表 - PHP 5.3 之前的准备语句

javascript - AngularJS 在 Controller 中注入(inject)模块

html - 相对 parent 的位置固定不在 firefox 中工作

PHP session 变量和 jQuery

php - 检查产品是否已购买