本文整理汇总了PHP中Source::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Source::save方法的具体用法?PHP Source::save怎么用?PHP Source::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Source
的用法示例。
在下文中一共展示了Source::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateSources
public function updateSources($get, $post)
{
$sources = file_get_contents("http://api.pnd.gs/v1/sources/");
$sources = json_decode($sources, true);
$my_sources = [];
foreach ($sources as $source) {
// get source and store it in an array
$my_source = [];
$my_source["panda_id"] = $source["_id"];
$my_source["key"] = $source["key"];
$my_source["name"] = $source["name"];
$my_source["description"] = $source["description"];
$my_source["category"] = $source["category"];
$my_source["type"] = $source["type"];
$my_source["icon"] = $source["icon"];
$my_source["color"] = $source["ios"]["color"];
$my_source["popularity"] = $source["stats"]["popularity"];
$my_source["popular_endpoint"] = NULL;
$my_source["latest_endpoint"] = NULL;
if ($source["popular"]) {
$my_source["popular_endpoint"] = $source["endpoints"]["popular"];
}
if ($source["latest"]) {
$my_source["latest_endpoint"] = $source["endpoints"]["latest"];
}
$display_settings = $source["settings"]["display"];
// meta stuff
$supported_meta = [];
if ($display_settings["views"]) {
array_push($supported_meta, "views");
}
if ($display_settings["votes"]) {
array_push($supported_meta, "votes");
}
if ($display_settings["comments"]) {
array_push($supported_meta, "comments");
}
if ($display_settings["author"]) {
array_push($supported_meta, "author");
}
$my_source["meta"] = implode(",", $supported_meta);
$s = new Source($this->ds);
$s = $s->withPandaId($my_source["panda_id"]);
if (is_null($s)) {
$s = new Source($this->ds);
}
$s->fromRow($my_source);
$s->save();
array_push($my_sources, $s);
}
function cmp($a, $b)
{
if ($a->popularity == $b->popularity) {
return 0;
}
return $a->popularity > $b->popularity ? -1 : 1;
}
usort($my_sources, "cmp");
$this->response->add("sources", $my_sources);
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Source();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Source'])) {
$model->attributes = $_POST['Source'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id_source));
}
}
$this->render('create', array('model' => $model));
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new ExternalSource();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['ExternalSource'])) {
//Creates new Source, gets generated ID
$source = new Source();
$source->save();
$model->attributes = $_POST['ExternalSource'];
//Gives the new external source the generated ID
$model->id_source = $source->id_source;
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id_source));
} else {
$source->delete();
}
}
$this->render('create', array('model' => $model));
}
示例4: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$cur_user = Yii::app()->user->id;
$user = User::Model()->findAllByAttributes(array('id' => $cur_user));
if ($user[0]['superuser'] == 1 or $user[0]['superuser'] == 2) {
$model = new Source();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Source'])) {
$model->attributes = $_POST['Source'];
$model->s_created = date('Y-m-d');
$model->s_modified = date('Y-m-d');
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->s_id));
}
}
$this->render('create', array('model' => $model));
} else {
echo "!Error 504 Page Not Found";
}
}
示例5: create
public static function create($path, $origin = "upload"){
$id = self::getID($path);
// If a Source object for this file already exists, there is no need to recompute its attributes
if(self::exists($id)) return new Source($id);
$source = new Source($id);
$source->origin = $origin;
if(!self::analyzable($path)){
throw new SourceCreateException("There is no Analyzer defined for this file");
}
$source->type = self::getType($path);
$analyzerName = "{$source->type}Analyzer";
$analyzer = new $analyzerName($path);
$source->features = $analyzer->analyze();
$source->save();
return $source;
}