本文整理汇总了PHP中DB_DataObject::pkName方法的典型用法代码示例。如果您正苦于以下问题:PHP DB_DataObject::pkName方法的具体用法?PHP DB_DataObject::pkName怎么用?PHP DB_DataObject::pkName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_DataObject
的用法示例。
在下文中一共展示了DB_DataObject::pkName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTagsArray
/**
* @param DB_DataObject $obj the recordset on which the select query will be executed
*/
public function getTagsArray($obj)
{
if (is_array($obj->_tagplugin_cache)) {
return $obj->_tagplugin_cache;
}
if (empty($obj->tagplugin_cache)) {
$tag = DB_DataObject::factory('tag');
$dbo = DB_DataObject::factory('tag_record');
$dbo->tagged_table = $obj->tableName();
$dbo->record_id = $obj->pk();
$tag->selectAdd();
$tag->selectAdd('tag.id,tag.strip');
$tag->joinAdd($dbo);
$tag->selectAs($dbo, 'link_%s');
$tag->find();
$obj->tagplugin_cache = '|';
while ($tag->fetch()) {
if (empty($tag->strip)) {
continue;
}
$obj->tagplugin_cache .= $tag->strip . '|';
$obj->_tagplugin_cache[] = $tag->strip;
}
$db = $obj->getDatabaseConnection();
$query = sprintf('UPDATE %s SET tagplugin_cache=:cacheval where %s = :pkval', $db->quoteIdentifier($obj->tableName()), $db->quoteIdentifier($obj->pkName()));
$sth = $db->prepare($query, array('text', 'text'));
if (PEAR::isError($sth)) {
throw new Exception($sth->getMessage() . ' HINT: check if your table has a tagplugin_cache field');
}
$sth->execute(array('cacheval' => $obj->tagplugin_cache, 'pkval' => $obj->pk()));
}
$obj->_tagplugin_cache = explode('|', $obj->tagplugin_cache);
return $obj->_tagplugin_cache;
}