我不太确定这个错误是什么,从环顾四周,它一定是与数据库声明有关。我试图在我的小工具上做一个下拉框,通过选择数据库的不同字段,将选择不同的掩码,并允许在以后的页面上制作不同的小工具。
我认为错误所在的代码部分是:
$this->build("p4a_db_source", "login")
->setTable("meetingrooms")
->addJoin("login.meetingrooms",
"login.meetingrooms.MeetingRoom = login.meetingrooms.MeetingRoom",
array('position'=>'Ident'))
->addOrder("position")
->load();
$this->setSource($this->login);
$this->firstRow();
$this->build('p4a_field','location')
->setSource('login')
->setLabel('location')
->setValue('Please Select...')
->setType('select')
->setWidth(60);
$this->weight->label->setWidth(60);我知道这是一个与我之前的问题类似的问题,但这是一个完全不同的代码,但这个问题应该更容易解决。谢谢你的帮助。
堆栈跟踪(致命错误:对C:\xampp\htdocs\p4a\p4a\objects\widgets\field.php中第468行的非对象上的成员函数getPk()的调用)没有指示错误发生的行,因此我不确定问题的确切来源。
代码的其余部分(包括前面的代码)是:
class main_dashboard_mask extends P4A_Base_Mask
{
public function __construct()
{
parent::__construct();
$this->setTitle("Dashboard");
$this->build('p4a_field','MeetingRooms');
$this->MeetingRooms->setLabel("This is the meeting room label");
$this->build('p4a_button', 'continue')
->setLabel('Continue?')
->implement("onclick", $this, "change");
$this->build('p4a_field','booking')
->setlabel('Viewing?')
->setType('checkbox')
->setValue(true);
$this->booking->label->setTooltip('If you are booking a meeting room, check this box');
$this->build("p4a_db_source", "login")
->setTable("meetingrooms")
->addJoin("login.meetingrooms",
"login.meetingrooms.MeetingRoom = login.meetingrooms.MeetingRoom",
array('position'=>'Ident'))
->addOrder("position")
->load();
$this->setSource($this->login);
$this->firstRow();
$this->build('p4a_field','location')
->setSource('login')
->setLabel('location')
->setValue('Please Select...')
->setType('select')
->setWidth(60);
$this->weight->label->setWidth(60);
$this->Meetingrooms();
}
private function Meetingrooms()
{
$this->build('P4A_fieldset', 'widgetframe')
->anchor($this->location)
->anchorLeft($this->booking)
->anchorLeft($this->continue)
->setLabel('Meeting Room Bookings');
}
}发布于 2012-10-23 22:06:12
我明白了,很抱歉我找对了地方,但没有看到我哪里错了…
在此之前,代码是->
$this->setSource($this->login);
$this->firstRow();
$this->build('p4a_field','location')
->setSource('login') // <- this is the error(the Pk variable hasn't been set here)
->setLabel('location')
->setValue('Please Select...')
->setType('select')
->setWidth(60);
$this->weight->label->setWidth(60);
$this->Meetingrooms();修复方法是->
->setSource($this->login)感谢您的帮助=]
发布于 2012-10-23 19:25:47
我认为你没有得到对象。这就是为什么它给出了非对象的错误。只需打印要对其调用方法getPk()的对象。如果它是有效对象,则只调用该方法。
发布于 2012-10-23 19:25:36
你有完整的堆栈跟踪吗?到底是哪一行代码生成了这个错误?
无论如何,您必须找到调用$object->getPk()的代码。该错误表示您正在尝试对为null的$object使用函数->getPk()。
https://stackoverflow.com/questions/13029307
复制相似问题