我正在为 ILIAS 制作一个插件,当我尝试调用与数据库相关的任何内容时,我遇到了这个错误。我在配置文件中包含了 dbupdate 文件,以便能够在开发插件时对其进行更新和更改。
(这是因为我相信 ILIAS 在安装插件时只使用 dbupdate。)
它给出错误的代码:
if(!$ilDB->tableColumnExists('rep_robj_xptg_data','id'))
{
$ilDB->addTableColumn(
'rep_robj_xptg_data',
'id',
array(
'type' => 'integer',
'length' => 4000
)
);
}
列和“id”确实存在于数据库中。我相信这需要能够在将来将数据保存到数据库中。
更新
这是“调用”的代码:
<?php
include ("/Customizing/global/plugins/Services/Repository/RepositoryObject/Presentations2Go/sql/dbupdate.php");
require_once('./Services/Component/classes/class.ilPluginConfigGUI.php');
require_once('class.ilPresentations2GoPlugin.php');
require_once('class.ilObjPresentations2Go.php');
//require ("/Customizing/global/plugins/Services/Repository/RepositoryObject/Presentations2Go/sql/dbupdate.php");
/**
* Presentations2Go configuration user interface class
*
* @author Bonny van den Bovenkamp
* @version $Id$
*
*/
class ilPresentations2GoConfigGUI extends ilPluginConfigGUI
{
/**
* Handles all commmands, default is "configure"
*/
function performCommand($cmd)
{
switch ($cmd)
{
case "configure":
case "save":
$this->$cmd();
break;
}
}
/**
* Configure screen
*/
function configure()
{
global $tpl;
$form = $this->initConfigurationForm();
$tpl->setContent($form->getHTML());
}
//
// From here on, this is just an Presentations2Go implementation using
// a standard form (without saving anything)
//
/**
* Init configuration form.
*
* @return object form object
*/
public function initConfigurationForm()
{
global $lng, $ilCtrl;
$pl = $this->getPluginObject();
include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
// setting 1 (a checkbox)
$cb = new ilCheckboxInputGUI($pl->txt("setting_1"), "setting_1");
$form->addItem($cb);
// setting 2 (text)
$ti = new ilTextInputGUI($pl->txt("setting_2"), "setting_2");
$ti->setRequired(true);
$ti->setMaxLength(10);
$ti->setSize(10);
$form->addItem($ti);
$form->addCommandButton("save", $lng->txt("save"));
$form->setTitle($pl->txt("Presentations2Go configuration"));
$form->setFormAction($ilCtrl->getFormAction($this));
return $form;
}
/**
* Save form input (currently does not save anything to db)
*
*/
public function save()
{
global $tpl, $lng, $ilCtrl;
$pl = $this->getPluginObject();
$form = $this->initConfigurationForm();
if ($form->checkInput())
{
$set1 = $form->getInput("setting_1");
$set2 = $form->getInput("setting_2");
ilUtil::sendSuccess($pl->txt("saving_invoked"), true);
$ilCtrl->redirect($this, "configure");
}
else
{
$form->setValuesByPost();
$tpl->setContent($form->getHtml());
}
}
}
?>
这是被调用的文件:
<?php
if(!$ilDB->tableColumnExists('rep_robj_xptg_data','id'))
{
$ilDB->addTableColumn(
'rep_robj_xptg_data',
'id',
array(
'type' => 'integer',
'length' => 4
)
);
}
if(!$ilDB->tableColumnExists('rep_robj_xptg_data','is_online'))
{
$ilDB->addTableColumn(
'rep_robj_xptg_data',
'is_online',
array(
'type' => 'integer',
'length' => 4
)
);
}
if(!$ilDB->tableColumnExists('rep_robj_xptg_data','option_one'))
{
$ilDB->addTableColumn(
'rep_robj_xptg_data',
'option_one',
array(
'type' => 'text',
'length' => 4
)
);
}
if(!$ilDB->tableColumnExists('rep_robj_xptg_data','option_two'))
{
$ilDB->addTableColumn(
'rep_robj_xptg_data',
'option_two',
array(
'type' => 'text',
'length' => 4
)
);
}
if(!$ilDB->tableColumnExists('rep_robj_xptg_data','option_three'))
{
$ilDB->addTableColumn(
'rep_robj_xptg_data',
'option_three',
array(
'type' => 'text',
'length' => 4
)
);
}
?>