Sql注入和updateall cakephp问题

Sql注入和updateall cakephp问题,php,cakephp,Php,Cakephp,当我使用这个查询时,我在cakephp中遇到了一个问题 $this->Rh->CompetencesUser->updateAll(array( 'CompetencesUser.niveau' => "'$value[1]'", 'CompetencesUser.expertise' => $value[2], 'CompetencesUser.rh_id' => $this->Rh->getLastInsertId()

当我使用这个查询时,我在cakephp中遇到了一个问题

$this->Rh->CompetencesUser->updateAll(array(
    'CompetencesUser.niveau' => "'$value[1]'",
    'CompetencesUser.expertise' => $value[2],
    'CompetencesUser.rh_id' => $this->Rh->getLastInsertId()
), array(
    'CompetencesUser.user_id' => $this->request->params['pass'][0],
    'CompetencesUser.competence_id' => $value[3]
));
它可以工作,但当我在字段
$value[1]
中输入一些字符时,它会显示一个错误,因此我如何转义这个字符或使用其他方法,因为如果不添加这些引号,
$value[1]
就无法工作。

如“应该使用DboSource::value()手动引用文字值”中所述

例如:-

$db = $this->Rh->CompetencesUser->getDataSource();
$this->Rh->CompetencesUser->updateAll(
    ['CompetencesUser.niveau' => $db->value($value[1], 'string')],
    [ // Some conditions ]
);
在大多数情况下,
updateAll()
不是保存数据的正确方法,而
save()
更适合。查看“应使用DboSource::value()手动引用文字值”中所述的

例如:-

$db = $this->Rh->CompetencesUser->getDataSource();
$this->Rh->CompetencesUser->updateAll(
    ['CompetencesUser.niveau' => $db->value($value[1], 'string')],
    [ // Some conditions ]
);
在大多数情况下,
updateAll()
不是保存数据的正确方法,而
save()
更适合。查看“应使用DboSource::value()手动引用文字值”中所述的

例如:-

$db = $this->Rh->CompetencesUser->getDataSource();
$this->Rh->CompetencesUser->updateAll(
    ['CompetencesUser.niveau' => $db->value($value[1], 'string')],
    [ // Some conditions ]
);
在大多数情况下,
updateAll()
不是保存数据的正确方法,而
save()
更适合。查看“应使用DboSource::value()手动引用文字值”中所述的

例如:-

$db = $this->Rh->CompetencesUser->getDataSource();
$this->Rh->CompetencesUser->updateAll(
    ['CompetencesUser.niveau' => $db->value($value[1], 'string')],
    [ // Some conditions ]
);

在大多数情况下,
updateAll()
不是保存数据的正确方法,而
save()
更适合。查看一下

@Holt,根据:$fields数组接受SQL表达式,因此应该手动引用文本值。我认为应该这样做,但当我给出例如home这样的字符串时,我得到了这样一个SQL错误,即field home unknown列,因为其中没有引号。它应该是类似于“家”的东西,而且很有效。我发现加上我为什么要问的引号是非常愚蠢的。蛋糕应该这样做好了,现在我明白了,谢谢you@Holt根据:$fields数组接受SQL表达式,所以应该手动引用文本值。我想是这样的,但是当我给出一个类似home的字符串时,我得到了一个SQL错误,说field home unknown列,因为其中没有引号。它应该是类似于“家”的东西,而且很有效。我发现加上我为什么要问的引号是非常愚蠢的。蛋糕应该这样做好了,现在我明白了,谢谢you@Holt根据:$fields数组接受SQL表达式,所以应该手动引用文本值。我想是这样的,但是当我给出一个类似home的字符串时,我得到了一个SQL错误,说field home unknown列,因为其中没有引号。它应该是类似于“家”的东西,而且很有效。我发现加上我为什么要问的引号是非常愚蠢的。蛋糕应该这样做好了,现在我明白了,谢谢you@Holt根据:$fields数组接受SQL表达式,所以应该手动引用文本值。我想是这样的,但是当我给出一个类似home的字符串时,我得到了一个SQL错误,说field home unknown列,因为其中没有引号。它应该是类似于“家”的东西,而且很有效。我发现加上我为什么要问的引号是非常愚蠢的。蛋糕应该这样做好吧现在我明白了,谢谢在我的例子中,我不得不使用updateAll,因为Cake 2拒绝承认复合主键是什么。在我的例子中,我不得不使用updateAll,因为Cake 2拒绝承认复合主键是什么。在我的例子中,我不得不使用updateAll,因为Cake 2拒绝承认复合主键是什么。在我的例子中,我不得不使用updateAllupdateAll,因为Cake 2拒绝确认复合主键是什么。