本文整理汇总了PHP中Record::getKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Record::getKey方法的具体用法?PHP Record::getKey怎么用?PHP Record::getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record::getKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doRegister
/**
* Implement the select-delete-insert
* This is in SQLResource because it's not generic, file resource
* will just overwrite existing record, but we can't insert if the
* row is present
* @param Record $record
*/
protected function doRegister($record)
{
$data = $record->toAssoc();
$data['lastModified'] = time();
$data['content'] = serialize($data['content']);
// This already deletes the stale records from DB
$r = $this->doRetrieve($record->getKey());
if ($r instanceof Record) {
$this->doDelete($record->getKey());
}
$k = $this->dbc->insert($data);
if ($k !== false) {
return $record->getKey();
}
return false;
}
示例2: doRegister
/**
* Implementation specific low level write operation
*
* @param Record $record
* @return boolean
*/
protected function doRegister($record)
{
$key = $record->getKey();
// Dump to file
$file_path = $this->key2filepath($key);
// Added support for multi-dir scalable file storage
if (!file_exists(dirname($file_path))) {
mkdir(dirname($file_path), 0777, true);
}
// Mutex lock for writes
if (!file_put_contents($file_path, serialize($record), LOCK_EX)) {
self::$log->error("Unable to write record to file: " . $key);
return false;
}
return true;
}