本文整理汇总了PHP中self::replace方法的典型用法代码示例。如果您正苦于以下问题:PHP self::replace方法的具体用法?PHP self::replace怎么用?PHP self::replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类self
的用法示例。
在下文中一共展示了self::replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mark
public static function mark(GWF_User $user, GWF_Links $link, $bool)
{
$userid = $user->getID();
$linkid = $link->getID();
$is_fav = self::table(__CLASS__)->getRow($userid, $linkid) !== false;
if ($is_fav === $bool) {
return true;
}
$row = new self(array('lf_uid' => $userid, 'lf_lid' => $linkid));
if ($bool) {
if (!$row->replace()) {
return false;
}
} else {
if (!$row->delete()) {
return false;
}
}
if (false === $link->increase('link_favcount', $bool ? 1 : -1)) {
return false;
}
if (false === $link->onCalcPopularity()) {
return false;
}
return true;
}
示例2: onRequest
/**
* Someone requested chat stuff.
* @param Module_Chat $module
* @return unknown_type
*/
public static function onRequest(Module_Chat $module)
{
// GWF_ChatMsg::cleanupTable($module);
$time = time();
$sessid = GWF_Session::getSessID();
if (false === ($nick = $module->getNickname())) {
$nick = self::getRandomNickS($sessid);
}
$table = self::table(__CLASS__);
if (false === ($row = $table->getRow($sessid))) {
# Unknown row
$row = new self(array('chaton_sessid' => $sessid, 'chaton_name' => $nick, 'chaton_timejoin' => $time, 'chaton_timeaccess' => $time));
$row->replace();
} else {
if ($row->getVar('chaton_timeleft') > 0) {
$row->saveVars(array('chaton_timejoin' => $time, 'chaton_timeaccess' => $time, 'chaton_timeleft' => 0));
} else {
if ($row->getVar('chaton_name') !== $nick) {
$row->saveVars(array('chaton_timeleft' => $time));
$row = new self(array('chaton_sessid' => $sessid, 'chaton_name' => $nick, 'chaton_timejoin' => $time, 'chaton_timeaccess' => $time));
$row->replace();
} else {
$row->saveVars(array('chaton_timeaccess' => $time));
}
}
}
self::cleanupTable($module);
return '';
}
示例3: getOrCreateByServer
public static function getOrCreateByServer(Dog_Server $server)
{
if (false !== ($stats = self::getByServer($server))) {
return $stats;
}
$stats = new self(array('dis_sid' => $server->getID(), 'dis_ip' => NULL, 'dis_software' => NULL, 'dis_max_users' => '0', 'dis_max_chans' => '0', 'dis_created_at' => NULL));
return $stats->replace() ? $stats : false;
}
示例4: addTag
public static function addTag($linkid, $tagid)
{
$maprow = new self(array('ltm_lid' => $linkid, 'ltm_ltid' => $tagid));
if (false === $maprow->replace()) {
return false;
}
return $maprow;
}
示例5: createPeak
public static function createPeak($cid, $count = 0, $options = 0)
{
$peak = new self(array('lcpeak_cid' => $cid, 'lcpeak_peak' => $count, 'lcpeak_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'lcpeak_options' => 0));
if (false === $peak->replace()) {
return false;
}
return $peak;
}
示例6: createStats
public static function createStats(SR_Player $player)
{
$stats = new self(array('sr4ps_pid' => $player->getID(), 'sr4ps_i_looted' => 0, 'sr4ps_i_sold' => 0, 'sr4ps_i_bought' => 0, 'sr4ps_i_dropped' => 0, 'sr4ps_i_given' => 0, 'sr4ps_i_received' => 0, 'sr4ps_ny_loot' => 0, 'sr4ps_ny_spent' => 0, 'sr4ps_ny_income' => 0, 'sr4ps_ny_given' => 0, 'sr4ps_ny_received' => 0, 'sr4ps_kill_mob' => 0, 'sr4ps_kill_npc' => 0, 'sr4ps_kill_human' => 0, 'sr4ps_kill_runner' => 0));
if (false === $stats->replace()) {
return false;
}
return $stats;
}
示例7: createChannelRecord
public static function createChannelRecord(Dog_Channel $channel)
{
$row = new self(array('dqj_cid' => $channel->getID(), 'dqj_sid' => $channel->getVar('chan_sid'), 'dqj_uid' => 0, 'dqj_duration' => 9999.999900000001, 'dqj_date_quit' => str_repeat('0', 14), 'dqj_date_join' => str_repeat('0', 14), 'dqj_options' => 0));
if (false === $row->replace()) {
return false;
}
return $row;
}
示例8: setFavorite
public static function setFavorite($userid, $siteid, $bool)
{
$entry = new self(array('sitefav_uid' => $userid, 'sitefav_sid' => $siteid));
if ($bool === true) {
return $entry->replace();
} else {
return $entry->delete();
}
}
示例9: createPMOptions
private static function createPMOptions(GWF_User $user)
{
$row = new self(array('pmo_uid' => $user->getVar('user_id'), 'pmo_options' => 0, 'pmo_auto_folder' => 0, 'pmo_signature' => '', 'pmo_level' => 0));
if (false === $row->replace()) {
return false;
}
// $row->setVar('pmo_uid', $user);
return $row;
}
示例10: createToken
/**
* @param $userid int
* @param $type string
* @param $data string
* @return string new token
*/
public static function createToken($userid, $type, $data = false)
{
$token = GWF_Random::randomKey(self::TOKEN_LENGTH);
$gdodata = array('userid' => $userid, 'type' => $type, 'token' => $token, 'timestamp' => time());
if (is_string($data)) {
$gdodata['data'] = $data;
}
$ac = new self($gdodata);
return false === $ac->replace() ? false : $token;
}
示例11: getOrCreateComments
/**
* Get a comments thread.
* @param string $key
* @param int $uid
* @param int $gid
* @param int $options
* @return GWF_Comments
*/
public static function getOrCreateComments($key, $uid = 0, $gid = 0, $options = self::DEFAULT_OPTIONS)
{
if (false !== ($c = self::getComments($key))) {
return $c;
}
$c = new self(array('cmts_id' => '0', 'cmts_key' => $key, 'cmts_uid' => $uid, 'cmts_gid' => $gid, 'cmts_count' => 0, 'cmts_thx' => 0, 'cmts_up' => 0, 'cmts_down' => 0, 'cmts_options' => $options));
if (false === $c->replace()) {
return false;
}
return $c;
}
示例12: createByPath
private static function createByPath($fullpath)
{
if (!is_file($fullpath) || !is_readable($fullpath)) {
return $fullpath;
}
$file = new self(array('lf_name' => $fullpath, 'lf_rev' => 0, 'lf_editor' => 0, 'lf_editat' => 0, 'lf_size' => filesize($fullpath), 'lf_data' => file_get_contents($fullpath)));
if (false === $file->replace()) {
return false;
}
return $file;
}
示例13: insertNote
public static function insertNote(GWF_User $user, $note)
{
# no empty notes
if ($note === '') {
return false;
}
# insert it
$entry = new self(array('accrm_uid' => $user->getVar('user_id'), 'accrm_note' => $note));
if (false === $entry->replace()) {
return false;
}
return $note;
}
示例14: getLevel
public static function getLevel(WC_Warbox $box, $level)
{
$boxid = $box->getID();
$elevel = self::escape($level);
if (false !== ($chall = self::table(__CLASS__)->selectFirstObject('*', "wc_boxid={$boxid} AND wc_level='{$elevel}'", '', '', NULL))) {
return $chall;
}
$chall = new self(array('wc_id' => '0', 'wc_boxid' => $boxid, 'wc_level' => $level, 'wc_score' => '1', 'wc_solvers' => '0', 'wc_created_at' => GWF_Time::getDate(), 'wc_last_solved_at' => NULL, 'wc_last_solved_by' => NULL));
if (!$chall->replace()) {
return false;
}
return $chall;
}
示例15: setWatching
public static function setWatching(GWF_ForumThread $thread, $cut)
{
$tid = $thread->getID();
# Insert current spectator
// GDO::table(__CLASS__);
$row = new self(array('fowa_sess' => GWF_Session::getSessID(), 'fowa_time' => time(), 'fowa_tid' => $tid));
if (false === $row->replace()) {
return false;
}
# Delete old
$cut = time() - $cut;
if (false === $row->deleteWhere("fowa_time<{$cut}")) {
return false;
}
# Set new amount
if (false === $thread->saveVar('thread_watchers', $row->countRows("fowa_tid={$tid}"))) {
return false;
}
return true;
}