将某些字段保存为null但它们确实有数据

时间:2016-02-08 20:33:23

标签: cakephp cakephp-3.0

我正在尝试插入新记录,但它不保存字段:numAndares,numAptos和numTipo。将它们保存为null。

'condominio_id'和'nome'正确保存。

我的newEntity在保存之前和之后:

\src\Controller\CondominiosController.php (line 142)
object(App\Model\Entity\Torre) {

    'condominio_id' => (int) 59,
    'numAndares' => (int) 0,
    'numAptos' => (int) 11,
    'numTipo' => (int) 0,
    'nome' => (int) 1,
    '[new]' => true,
    '[accessible]' => [
        '*' => true
    ],
    '[dirty]' => [
        'condominio_id' => true,
        'numAndares' => true,
        'numAptos' => true,
        'numTipo' => true,
        'nome' => true
    ],
    '[original]' => [],
    '[virtual]' => [],
    '[errors]' => [],
    '[invalid]' => [],
    '[repository]' => 'Torres'

}
\src\Controller\CondominiosController.php (line 146)
object(App\Model\Entity\Torre) {

    'condominio_id' => (int) 59,
    'numAndares' => (int) 0,
    'numAptos' => (int) 11,
    'numTipo' => (int) 0,
    'nome' => (int) 1,
    'id' => (int) 44,
    '[new]' => false,
    '[accessible]' => [
        '*' => true
    ],
    '[dirty]' => [],
    '[original]' => [],
    '[virtual]' => [],
    '[errors]' => [],
    '[invalid]' => [],
    '[repository]' => 'Torres'

}

当我保存时:

$torre = $torreTable->newEntity();
$torre->condominio_id = $condominio->id;
$torre->numAndares = 0;
$torre->numAptos = 11;
$torre->numTipo = 0;
$torre->nome = $x+1;

debug($torre);
if ($torreTable->save($torre)) {
    debug($torre);

任何帮助?

0 个答案:

没有答案