我正在为我正在构建的应用程序运行 CodeIgniter 1.7.3、Datamapper DMZ 1.7.1(不,升级不是一种选择)、MySQL 5.1 和Cron Job Boostrapper 。我正在尝试从 XML 文件中提取信息并将其保存到数据库中。获取数据工作得很好,从数据库获取数据也是如此,所以我知道这既不是数据库连接的问题,也不是 XML 文件的问题。
$this->site = $this->site->get_by_short_name('site');
//Load the XML files into variables so we can do stuff with them.
$doctors = simplexml_load_file(realpath('../xml/doctors.xml'));
foreach ($doctors->children() as $doctor) {
$dr = new Doctor();
$attrs = $doctor->attributes();
/* See if the Doctor already exists. If so, update it.
* Datamapper won't update fields that don't change, so if nothing's
* changed, then the DB call won't be made.
*/
$dr->get_by_drkey($attrs['Key']);
$dr->drkey = $attrs['Key'];
$dr->first_name = $doctor->FirstName;
$dr->middle_name = $doctor->MiddleName;
$dr->last_name = $doctor->LastName;
$dr->long_name = $doctor->LongName;
$dr->degrees = $doctor->Degrees;
$dr->pic = $doctor->ImageURL;
$dr->save($this->site);
}
我检查了的返回值,$dr->save($this->site)
它返回为真(“成功保存”),但数据没有保存,也没有错误。我试过没有关系(在数据库中删除了对它的要求),所以它应该没有错误地保存,但它仍然没有保存。我还仔细检查了模型中的关系设置,它们很好。
我还尝试绕过 Datamapper 并直接$this->db->insert('doctors',$data)
将数据转换为数组,但数据仍然没有保存。我还尝试从浏览器运行它(绕过引导程序)以查看问题是否与从命令行运行有关,但这也不起作用。我也没有自动加载任何会话或身份验证库,因此不会触发引导程序的已知问题。
有没有人知道为什么这可能不起作用?