本文整理汇总了PHP中Conversation::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Conversation::insert方法的具体用法?PHP Conversation::insert怎么用?PHP Conversation::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conversation
的用法示例。
在下文中一共展示了Conversation::insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Factory method for creating a new conversation.
*
* Use this for locally initiated conversations. Remote notices should
* preferrably supply their own conversation URIs in the OStatus feed.
*
* @return Conversation the new conversation DO
*/
static function create(Notice $notice, $uri = null)
{
if (empty($notice->id)) {
throw new ServerException(_('Tried to create conversation for not yet inserted notice'));
}
$conv = new Conversation();
$conv->created = common_sql_now();
$conv->id = $notice->id;
$conv->uri = $uri ?: sprintf('%s%s=%d:%s=%s:%s=%x', TagURI::mint(), 'noticeId', $notice->id, 'objectType', 'thread', 'crc32', crc32($notice->content));
$result = $conv->insert();
if ($result === false) {
common_log_db_error($conv, 'INSERT', __FILE__);
throw new ServerException(_('Failed to create conversation for notice'));
}
return $conv;
}
示例2: create
/**
* Factory method for creating a new conversation
*
* @return Conversation the new conversation DO
*/
static function create()
{
$conv = new Conversation();
$conv->created = common_sql_now();
$id = $conv->insert();
if (empty($id)) {
common_log_db_error($conv, 'INSERT', __FILE__);
return null;
}
$orig = clone $conv;
$orig->uri = common_local_url('conversation', array('id' => $id), null, null, false);
$result = $orig->update($conv);
if (empty($result)) {
common_log_db_error($conv, 'UPDATE', __FILE__);
return null;
}
return $conv;
}
示例3: create
/**
* Factory method for creating a new conversation.
*
* Use this for locally initiated conversations. Remote notices should
* preferrably supply their own conversation URIs in the OStatus feed.
*
* @return Conversation the new conversation DO
*/
static function create($uri = null, $created = null)
{
// Be aware that the Notice does not have an id yet since it's not inserted!
$conv = new Conversation();
$conv->created = $created ?: common_sql_now();
$conv->uri = $uri ?: sprintf('%s%s=%s:%s=%s', TagURI::mint(), 'objectType', 'thread', 'nonce', common_random_hexstr(8));
// This insert throws exceptions on failure
$conv->insert();
return $conv;
}