我有更新记录的功能,但我不能失败并向我发送“行中缺少主键 ID 或为空”消息,我该如何解决?
public static function update_child($data)
{
try
{
$update= ORM::for_table("dm_child",DM_TAG)
->where_equal($data["id_child"]);
$update -> set(array(
"gender" => $data["gender"]
"age_year" =>$data["year"]
"age_month" => $data["month"]
));
$update -> save();
}
catch(PDOException $ex)
{
ORM::get_db()->rollBack();
throw $ex;
}
}
最佳答案
Idiorm 假定主键的名称是“id”,但在您的情况下并非如此。 因此,您必须明确地将其指定为 Idiorm:
<?php
ORM::configure('id_column_overrides', array(
'dm_child' => 'id_child',
'other_table' => 'id_table',
));
参见 Docs>Configuration .
关于php - 使用 idiorm 和 php 更新一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27911939/