我正在尝试创建一个对象,但这些值没有存储到数据库中。这是在“索引”操作上完成的,因为插件是通过 TypoScript 插入的,实际上不会创建输出。所以调用动作时没有给出对象,这就是我自己创建它的原因。
$stat = new Tx_MyExt_Domain_Model_Stat;
$stat->setSubscriberId($_COOKIE['statid']);
$stat->setDomain($_SERVER['HTTP_HOST']);
$stat->setRequestUri($_SERVER['REQUEST_URI']);
$this->statRepository = t3lib_div::makeInstance('Tx_myExt_Domain_Repository_StatRepository');
$this->statRepository->add($stat);
做 avar_dump($stat)
给出以下内容:
object(Tx_MyExt_Domain_Model_Stat)#191 (9) {
["subscriber_id":protected]=>
string(1) "2"
["domain":protected]=>
string(22) "test.localhost.example"
["request_uri":protected]=>
string(26) "/testpage/index.php?id=2"
["uid":protected]=>
NULL
["_localizedUid":protected]=>
NULL
["_languageUid":protected]=>
NULL
["pid":protected]=>
NULL
["_isClone":"Tx_Extbase_DomainObject_AbstractDomainObject":private]=>
bool(false)
["_cleanProperties":"Tx_Extbase_DomainObject_AbstractDomainObject":private]=>
NULL
}
所以这看起来像正确分配了值。但是当查看数据库时,我得到了这个:
uid pid subscriber_id domain request_uri crdate
13 0 0 NULL NULL 1328176026
存储库:
class Tx_MyExt_Domain_Repository_StatRepository extends Tx_Extbase_Persistence_Repository
{}
模型:
class Tx_MyExt_Domain_Model_Stat extends Tx_Extbase_DomainObject_AbstractEntity
{
/**
* @var int
* @dontvalidate
*/
protected $subscriber_id = 0;
/**
* @var string
* @dontvalidate
*/
protected $domain = '';
/**
* @var string
* @dontvalidate
*/
protected $request_uri = '';
/**
* @param int $susbcriber_id Subscriber id
* @return void
*/
public function setSubscriberId($subscriber_id)
{
$this->subscriber_id = $subscriber_id;
}
/**
* @return int Susbcriber id
*/
public function getSubscriberId()
{
return $this->subscriber_id;
}
/**
* @param string $domain Domain
* @return void
*/
public function setDomain($domain)
{
$this->domain = $domain;
}
/**
* @return string Domain
*/
public function getDomain()
{
return $this->domain;
}
/**
* @param string $request_uri Request URI
* @return void
*/
public function setRequestUri($request_uri)
{
$this->request_uri = $request_uri;
}
/**
* @return string Request URI
*/
public function getRequestUri()
{
return $this->request_uri;
}
}
有人可以告诉我这里可能出了什么问题吗?