本文整理汇总了PHP中model::save方法的典型用法代码示例。如果您正苦于以下问题:PHP model::save方法的具体用法?PHP model::save怎么用?PHP model::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model
的用法示例。
在下文中一共展示了model::save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
$this->view = false;
// Views disabled
$model = new model();
$model->name = "name";
$model->size = 321;
$model->url = "http://example.com";
$model->save();
$model2 = model::findFirst(array("where" => "name = 'name'"));
$model2->name = "New name for old model";
$model->save();
return false;
}
示例2: actionUpload
public function actionUpload()
{
// header('Content-type: text/plain; charset=utf-8');
$settings = $this->getServerSettings();
//$myFile ="/Users/mac/dev/data/". "testFile.txt";
//$fh = fopen($myFile, 'w') or die("can't open file");
//$stringData = $_POST['photoxml'];
//fwrite($fh, $stringData);
//$stringData = $_POST['videoxml'];
///fwrite($fh, $stringData);
//fclose($fh);
$photoxml = simplexml_load_string($_POST['photoxml']);
//print_r($photoxml);
//exit;
$videoxml = simplexml_load_string($_POST['videoxml']);
$tracksxml = simplexml_load_string($_POST['tracksxml']);
$bwid = getBwId();
$authToken = $_POST['l'];
$email = file_get_contents("https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token={$authToken}");
if (!$email) {
// header(400);
return "";
}
//$zipfile=$_FILES['file'];
//get settings about this from server
$upload_location = $settings->upload_location;
$tmp_location = $settings->tmp_location;
move_uploaded_file($_FILES['file']['tmp_name'], $tmp_location . $_FILES['file']['name']);
$uuid = uniqid();
mkdir($tmp_location . "/" . $uuid, true);
//unzip file into tmp directory
$zip = new ZipArchive();
$res = $zip->open($tmp_location . $_FILES['file']['name']);
if ($res === TRUE) {
$zip->extractTo($tmp_location . "/" . $uuid);
$zip->close();
// echo 'woot!';
} else {
// echo 'doh!';
}
// unzip($tmp_location.$_FILES['file']['name'],$tmp_location."/".$uuid);
// $noofphotos = getNoOfPhotos($photoxml);
foreach ($photoxml->photo as $photo) {
$photoModel = new model('Photos');
$bwid = $photo['bwid'];
$photoModel->location = $upload_location . "/" . $bwid . "/photos/" . $photo['uri'];
$photoModel->bwid = $bwid;
$photoModel->gpslat = $photo['gpslat'];
$photoModel->gpslon = $photo['gpslon'];
$photoModel->gpsalt = $photo['gpslat'];
$photoModel->gpsacc = $photo['gpsacc'];
$photoModel->name = $photo['caption'];
$photoModel->save();
//save photo to upload_location
//open file $tmp_location."/".$uuid."/".$photo->attributes()->name
//save file to $upload_location."/".$bwid."/".$photoModel->id."/.jpg";
}
foreach ($videoxml->video as $video) {
$videoModel = new model('videos');
$bwid = $video['bwid'];
$videoModel->location = $upload_location . "/" . $bwid . "/videos/" . $video['uri'];
$videoModel->bwid = $bwid;
$videoModel->gpslat = $video['gpslat'];
$videoModel->gpslon = $video['gpslon'];
$videoModel->gpsalt = $video['gpslat'];
$videoModel->gpsacc = $video['gpsacc'];
$videoModel->name = $video['caption'];
$videoModel->save();
//save video to upload_location
//open file $tmp_location."/".$uuid."/".$video->attributes()->name
//save file to $upload_location."/".$bwid."/".$videoModel->id."/.jpg";
}
foreach ($tracksxml->track as $track) {
$trackModel = new model('Tracks');
$trackModel->location = $upload_location . "/" . $bwid . "/tracks/" . $video['uri'];
$trackModel->bwid = $bwid;
$trackModel->name = $track['caption'];
$trackModel->save();
//save photo to upload_location
//open file $tmp_location."/".$uuid."/".$photo->attributes()->name
//save file to $upload_location."/".$bwid."/".$photoModel->id."/.jpg";
}
}
示例3: transfer
function transfer()
{
$dbconfig = $this->config["dsn"];
include_once ROOT . "lib/vip/DBUtil.php";
include_once ROOT . "app/main/model.php";
$data = $this->model('mvc_comment')->peeks();
$dbconfig['charset'] = 'utf8';
$dbnew = new DB($dbconfig);
$modelnew = new model($dbnew, 'mvc_comment2');
echo '<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />';
foreach ($data as $i) {
echo $i[comment], "<br>";
$i[oldid] = $i[id];
$i[id] = null;
$modelnew->save($i);
}
exit;
}
示例4: saveImage
/**
* Upload image of user
*
* @param file $image
* @param model $user
* @param bool $saveAtTheEnd
*/
private function saveImage($image, $user, $saveAtTheEnd)
{
$fileLocation = base_path("storage/uploads/");
$ext = substr($image, 10);
$userTempImage = $fileLocation . $image;
$newUserImage = "storage/uploads/user_" . $user->id . $ext;
$oldUserImage = $user->img_url;
if (\File::exists($oldUserImage)) {
\File::delete($oldUserImage);
}
\File::move($userTempImage, base_path($newUserImage));
$user->img_url = $newUserImage;
if ($saveAtTheEnd) {
$user->save();
}
}