当前位置: 首页>>代码示例>>PHP>>正文


PHP Repository::persist方法代码示例

本文整理汇总了PHP中Repository::persist方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::persist方法的具体用法?PHP Repository::persist怎么用?PHP Repository::persist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Repository的用法示例。


在下文中一共展示了Repository::persist方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: canUpdateAnEntity

 /**
  * @test
  */
 public function canUpdateAnEntity()
 {
     $expectedConditions = array('id' => 1);
     $expectedParams = array('id' => 1, 'name' => 'foo', 'value' => 'bar');
     $this->storage->expects($this->once())->method('updateWhere')->with($expectedConditions, $expectedParams)->will($this->returnValue(1));
     $entity = $this->createEntity();
     $entity->setId(1);
     $this->repository->persist($entity);
 }
开发者ID:koinephp,项目名称:repository,代码行数:12,代码来源:IdAwareRepositoryTest.php

示例2: getArticle

 private function getArticle($article_id)
 {
     $params = array();
     $params = array('eq' => array('article_id' => $article_id));
     if (!$this->is_root) {
         $params['lt'] = array('category_id' => 5);
     }
     $article = Repository::findOneFromArticle($params);
     if ($article == false) {
         header("Location: /index/notfound");
         return;
     }
     $params['tags'] = SqlRepository::getTags($article_id);
     $params['title'] = $article->get_title();
     $params['indexs'] = json_decode($article->get_indexs());
     $params['contents'] = \TechlogTools::pre_treat_article($article->get_draft());
     $params['title_desc'] = $article->get_title_desc();
     $params['article_category_id'] = $article->get_category_id();
     if (StringOpt::spider_string($params['contents'], '"page-header"', '</div>') === null) {
         $params['contents'] = '<div class="page-header"><h1>' . $article->get_title() . '</h1></div>' . $params['contents'];
     }
     $article->set_access_count($article->get_access_count() + 1);
     Repository::persist($article);
     $params['inserttime'] = $article->get_inserttime() . '&nbsp;&nbsp;&nbsp;最后更新: ' . $article->get_updatetime() . '&nbsp;&nbsp;&nbsp;访问数量:' . ($article->get_access_count() + 1);
     return $params;
 }
开发者ID:junkings,项目名称:techlog,代码行数:26,代码来源:ArticleController.php

示例3: record_access

 public function record_access()
 {
     $remote_host = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '-';
     $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '-';
     $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '-';
     $stats = new StatsModel(array('time_str' => 'now()', 'remote_host' => $remote_host, 'request' => "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'referer' => $referer, 'user_agent' => $user_agent));
     Repository::persist($stats);
 }
开发者ID:junkings,项目名称:techlog,代码行数:8,代码来源:Controller.php

示例4: array

}
$month = $options['m'];
$income = (double) $options['i'];
$expend = (double) $options['e'];
$image_id = (int) $options['a'];
$sql = 'select path from images where image_id = ' . $image_id;
$path = Repository::findPathFromImages(array('eq' => array('image_id' => $image_id)));
if ($path == false) {
    LogOpt::set('exception', 'image_not_exists');
    return false;
}
$article = new ArticleModel(array('title' => $month . '财报', 'updatetime' => 'now()', 'inserttime' => 'now()', 'draft' => '<div>' . PHP_EOL . '<!-- 图片大小:700*467 -->' . PHP_EOL . '</div>', 'category_id' => 6));
$article_id = Repository::persist($article);
if ($article_id == false) {
    LogOpt::set('exception', 'new_note_insert_into_article_error');
    return false;
}
LogOpt::set('info', 'new_note_insert_into_article_success', 'article_id', $article_id);
$infos = array();
$infos['article_id'] = $article_id;
$infos['image_id'] = $image_id;
$infos['month'] = $month;
$infos['income'] = $income;
$infos['expend'] = $expend;
$earnings = new EarningsModel(array('article_id' => $article_id, 'image_id' => $image_id, 'month' => $month, 'income' => $income, 'expend' => $expend, 'inserttime' => 'now()'));
$earnings_id = Repository::persist($earnings);
if ($earnings_id == false) {
    LogOpt::set('exception', 'new_earnings_insert_into_booknote_error');
    return false;
}
LogOpt::set('info', 'new_earnings_insert_into_booknote_success', 'earnings_id', $earnings_id);
开发者ID:junkings,项目名称:techlog,代码行数:31,代码来源:earnings_loader.php

示例5: trim

        }
        $image_path = trim($image_path);
        if (!file_exists(WEB_PATH . '/resource/' . $image_path)) {
            LogOpt::set('exception', '文中目标图片不存在', 'image_path', $image_path);
            return;
        }
        $image_id = Repository::findImageIdFromImages(array('eq' => array('path' => $image_path)));
        if ($image_id == false) {
            $full_path = WEB_PATH . '/resource/' . $image_path;
            $image_id = TechlogTools::load_image($full_path, 'article');
            if ($image_id == false) {
                LogOpt::set('exception', '添加图片到数据库失败', 'image_path', $image_path);
                return;
            }
            LogOpt::set('info', '添加图片到数据库成功', 'image_id', $image_id, 'image_path', $image_path);
            $image_ids[] = $image_id;
        }
    }
    $article = Repository::findOneFromArticle(array('eq' => array('article_id' => $article_id)));
    foreach ($infos as $key => $value) {
        $func = 'set_' . $key;
        $article->{$func}($value);
    }
    $ret = Repository::persist($article);
    if ($ret == false) {
        LogOpt::set('exception', 'article 更新失败', 'article_id', $article_id);
        return;
    }
    LogOpt::set('info', 'article 更新成功', 'article_id', $ret);
    unlink($draft_file);
}
开发者ID:junkings,项目名称:techlog,代码行数:31,代码来源:contents_loader.php

示例6: load_image

 public static function load_image($path, $category = '')
 {
     $file_path = self::getfilepath($path);
     if (!file_exists($file_path)) {
         echo $file_path . PHP_EOL;
         return false;
     }
     $pos = strpos($file_path, '/html/');
     if ($pos === false) {
         return false;
     }
     $image = new ImagesModel(array('md5' => md5_file($file_path), 'path' => substr($file_path, $pos + strlen('/html/')), 'category' => $category, 'inserttime' => 'now()'));
     $id = Repository::persist($image);
     return $id;
 }
开发者ID:aleafboat,项目名称:techlog,代码行数:15,代码来源:TechlogTools.php

示例7: foreach

    return;
}
foreach ($tags as $tag) {
    $tag = trim($tag);
    if ($tag == '') {
        continue;
    }
    $tag_id = Repository::findTagIdFromTags(array('eq' => array('tag_name' => $tag)));
    if ($tag_id == false) {
        $tag = new TagsModel(array('tag_name' => $tag, 'inserttime' => 'now()'));
        $tag_id = Repository::persist($tag);
        if ($tag_id == false) {
            LogOpt::set('exception', 'tag 添加失败');
            continue;
        }
    }
    $article_tag_relation = new ArticleTagRelationModel(array('article_id' => $article_id, 'tag_id' => $tag_id, 'inserttime' => 'now()'));
    try {
        $relation_id = Repository::persist($article_tag_relation);
    } catch (PDOException $e) {
        LogOpt::set('exception', 'article_tag_relation 已存在', 'article_id', $article_id, 'tag_id', $tag_id);
        $pdo = Repository::getInstance();
        $pdo->rollback();
        continue;
    }
    if ($relation_id == false) {
        LogOpt::set('exception', 'article_tag_relation 更新失败', 'article_id', $article_id, 'tag_id', $tag_id);
        continue;
    }
    LogOpt::set('info', 'article_tag_relation 更新成功', 'relation_id', $relation_id);
}
开发者ID:aleafboat,项目名称:techlog,代码行数:31,代码来源:article_creater.php

示例8: intval

    return;
}
$bookname = $options['b'];
$image_id = intval(trim($options['i']));
$descs = isset($options['d']) ? $options['d'] : null;
$image = Repository::findOneFromImages(array('eq' => array('image_id' => $image_id)));
if ($image == false) {
    LogOpt::set('exception', 'image not exists', 'image_id', $image_id);
    return false;
}
$article = new ArticleModel(array('title' => $bookname, 'updatetime' => 'now()', 'inserttime' => 'now()', 'category_id' => 2));
$article_id = Repository::persist($article);
if ($article_id == false) {
    LogOpt::set('exception', 'new_note_insert_into_article_error');
    return false;
}
LogOpt::set('info', 'new_note_insert_into_article_success', 'article_id', $article_id);
$infos = array();
$infos['index_article_id'] = $article_id;
$infos['image_id'] = $image_id;
$infos['updatetime'] = 'now()';
if ($descs != null) {
    $infos['descs'] = $descs;
}
$booknote = new BooknoteModel(array('index_article_id' => $article_id, 'image_id' => $image_id, 'updatetime' => 'now()', 'inserttime' => 'now()'));
$note_id = Repository::persist($booknote);
if ($note_id == false) {
    LogOpt::set('exception', 'new_note_insert_into_booknote_error');
    return false;
}
LogOpt::set('info', 'new_note_insert_into_booknote_success', 'note_id', $note_id);
开发者ID:junkings,项目名称:techlog,代码行数:31,代码来源:note_loader.php

示例9: while

    }
    $mood_id = Repository::persist($mood);
    if ($mood_id === false) {
        LogOpt::set('exception', 'mood add error');
        continue;
    }
    LogOpt::set('info', 'mood add success', 'mood_id', $mood_id);
} else {
    echo 'usage: you can also use by ----' . ' php mood_loader -c contents [-i inserttime] [-d mood_id]' . PHP_EOL;
    while (1) {
        echo '> ';
        $contents = fgets(STDIN);
        $contents = trim($contents);
        if (strtolower($contents) === 'quit') {
            break;
        }
        if ($contents != '' && $contents != null) {
            echo '确认添加至说说吗? Y/N [N]:';
            $sure = fgets(STDIN);
            if (trim($sure[0]) == 'Y' || trim($sure[0]) == 'y') {
                $mood = new MoodModel(array('contents' => $contents));
                $mood_id = Repository::persist($mood);
                if ($mood_id === false) {
                    LogOpt::set('exception', 'mood add error', 'contents', $contents);
                    continue;
                }
                LogOpt::set('info', 'mood add success', 'mood_id', $mood_id);
            }
        }
    }
}
开发者ID:aleafboat,项目名称:techlog,代码行数:31,代码来源:mood_loader.php

示例10: array

    $image_id = Repository::findImageIdFromImages(array('eq' => array('path' => $image_path)));
    if ($image_id == false) {
        $full_path = WEB_PATH . '/resource/' . $image_path;
        $image_id = TechlogTools::load_image($full_path, 'article');
        if ($image_id == false) {
            LogOpt::set('exception', '添加图片到数据库失败', 'image_path', $image_path);
        }
        LogOpt::set('info', '添加图片到数据库成功', 'image_id', $image_id, 'image_path', $image_path);
        $image_ids[] = $image_id;
    }
}
$infos['title'] = date('Y-m-d H:i:s');
if (isset($options['t'])) {
    $infos['title'] = $options['t'] . ' -- ' . date('Y-m-d');
}
$infos['category_id'] = '5';
// 获取 index
$indexs = json_encode(TechlogTools::get_index($contents));
if ($indexs != null) {
    $infos['indexs'] = $indexs;
}
$infos['updatetime'] = 'now()';
$infos['inserttime'] = 'now()';
$article = new ArticleModel($infos);
$article_id = Repository::persist($article);
if ($article_id == false) {
    LogOpt::set('exception', 'article insert error');
    return;
}
LogOpt::set('info', '添加日志成功', 'article_id', $article_id, 'title', $infos['title']);
unlink($draft_file);
开发者ID:aleafboat,项目名称:techlog,代码行数:31,代码来源:diary_loader.php


注:本文中的Repository::persist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。