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


PHP Ad::save方法代码示例

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


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

示例1: testCreateAd

 /**
  * @covers Ad::tableName
  * @todo   Implement CreateAd().
  */
 public function testCreateAd()
 {
     $this->object->name = 'test Ad1';
     $this->object->description = 'test Ad1 description';
     $this->object->html = '<p>This is a test Ad</p>';
     $this->assertTrue($this->object->save() === TRUE);
 }
开发者ID:nurielmeni,项目名称:nymedia,代码行数:11,代码来源:AdTest.php

示例2: createFakerAd

 protected function createFakerAd()
 {
     $faker = Faker::create();
     $adtype = array("Informal Jam", "Formal Jam/Practice/Rehearsal", "Payed Gig", "Offering Lessons", "Wanting Lessons");
     $level = array("Beginner", "Intermediate", "Semi-Pro", "Professional");
     $original = array("Originals", "Covers", "Both");
     $venuetype = array("House", "Venue", "Recording Studio", "Event");
     $usertype = array("Band", "Musician");
     $genre = array("Acoustic Blues", "Electric Blues", "Bluegrass", "Classical", "Pop Country", "Traditional Country", "House", "Deep House", "Dubstep", "Trap", "Techno", "Downtempo", "Ambient", "Drums & Bass", "Video Game", "Americana", "Acoustic Folk", "Cajun Folk", "Celtic Folk", "Singer/Songwriter Folk", "Combo Jazz", "Dixieland Jazz", "Ensemble Jazz", "Fusion Jazz", "Latin Jazz", "Standards", "Acid Jazz", "Latin", "New Age", "Ambient", "Christian", "Classic Rock", "Dance", "Hard Rock", "Heavy Metal", "Indie Rock", "Latin Rock", "New Wave", "Pop", "Psychedelic", "Punk Rock", "Rock & Roll", "Rockabilly", "Singer/Songwriter", "Ska", "Soft Rock", "Southern Rock", "Top 40", "Hip Hop/Rap", "Classic Soul", "Neo-Soul", "Gospel", "Contemporary R&B", "Reggae", "Soundtrack", "World Music");
     $instrument = array("Full Band, Acoustic Guitar", "Classical Guitar", "Electric Guitar", "Steel Guitar", "Electric Bass", "Double Bass", "Ukelele", "Piano", "Keyboard", "Organ", "Accordion", "Drums", "Lead Rock/Pop Vocals", "Lead Jazz Vocals", "Bass Singer", "Baritone Singer", "Tenor Singer", "Alto Singer", "Mezzo-Soprano Singer", "Soprano Singer", "Cello", "Viola", "Violin", "Fiddle", "Banjo", "Harp", "Mandolin", "Trumpet", "Trombone", "Tuba", "French Horn", "Alto Sax", "Tenor Sax", "Flute", "Oboe", "Clarinet", "Harmonica", "Piccolo", "Bassoon");
     $equipment = array("P/A System", "Guitar Amp", "Bass Amp", "Drum Set", "Keyboard");
     for ($i = 1; $i <= 200; $i++) {
         $ad = new Ad();
         $ad->ad_type = $faker->randomElement($adtype);
         $ad->ad_need = implode(", ", $faker->randomElements($instrument, $count = rand(1, 3)));
         $ad->ad_title = $faker->state . " " . $faker->lastName;
         $ad->level = $faker->randomElement($level);
         $ad->comp = rand(0, 200);
         $ad->genre = implode(", ", $faker->randomElements($genre, $count = rand(1, 3)));
         $ad->date = $faker->dateTimeBetween($startDate = 'now', $endDate = '3 months');
         $ad->start_time = $faker->time($format = 'H:i:s', $min = 'now');
         $ad->description = $faker->realText;
         $ad->equipment = implode(", ", $faker->randomElements($equipment, $count = rand(0, 5)));
         $ad->venue_type = $faker->randomElement($venuetype);
         $ad->venue = "Tycoon Flats";
         $ad->address = "2926 N. St. Marys Street";
         $ad->city = "San Antonio";
         $ad->state = "TX";
         $ad->zip_code = "78212";
         $ad->user_id = User::all()->random(1)->id;
         $ad->ad_img = $faker->imageUrl($width = 640, $height = 480, $category = 'nightlife');
         $ad->save();
     }
 }
开发者ID:jamalots,项目名称:jamalot.dev,代码行数:34,代码来源:AdsTableSeeder.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     /*
      * Verifies access to the particular AD.
      */
     if (Yii::app()->user->checkAccess('AdCreate', $this->bizruleCreate())) {
         $model = new Ad();
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         if (isset($_POST['Ad'])) {
             $model->attributes = $_POST['Ad'];
             if ($model->save()) {
                 $screenAdAssignment = new ScreenAdAssignment();
                 $screenAdAssignment->ad_id = $model->id;
                 $screenAdAssignment->screen_id = $this->_screen->id;
                 if ($screenAdAssignment->save()) {
                     Yii::app()->user->setFlash('success', YII::t('ad', 'Ad created successfully.'));
                     $this->redirect(array('screen/view', 'id' => $this->_screen->id));
                 } else {
                     Yii::app()->user->setFlash('error', YII::t('ad', 'Could not assign the Ad to the Screen.'));
                     $model->delete();
                 }
             }
         }
         $this->render('create', array('model' => $model));
     } else {
         throw new CHttpException(403, YII::t('default', 'You are not authorized to perform this action.'));
     }
 }
开发者ID:nurielmeni,项目名称:nymedia,代码行数:33,代码来源:AdController.php

示例4: run

 public function run()
 {
     $model = new Ad();
     if (isset($_POST['Ad'])) {
         $model->attributes = $_POST['Ad'];
         //图片
         $model->attach_file = isset($_POST['attach_file']) ? $_POST['attach_file'] : '';
         if ($model->save()) {
             $this->controller->message('success', Yii::t('admin', 'Add Success'), $this->controller->createUrl('index'));
         }
     }
     $this->controller->render('create', array('model' => $model));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:13,代码来源:CreateAction.php

示例5: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Ad('create');
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Ad'])) {
         $model->attributes = $_POST['Ad'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:lhfcainiao,项目名称:basic,代码行数:17,代码来源:AdController.php

示例6: handlePostQuery

 public static function handlePostQuery(array $sanitized_post_array)
 {
     // The result of the request
     $ajax_result = array('status' => '', 'message' => '', 'data' => '');
     $is_edit_mode = isset($sanitized_post_array['id']);
     $ad = new Ad($sanitized_post_array);
     $result = $ad->save();
     $sanitized_title = htmlentities($ad->getTitle());
     if ($result) {
         $ajax_result['status'] = 'success';
         $ajax_result['message'] = 'Ad "' . $sanitized_title . '" has been ' . ($is_edit_mode ? '" updated' : '"added') . ' successfully .';
         $ajax_result['data'] = ['id' => $ad->getId()];
     } else {
         $ajax_result['status'] = 'error';
         $ajax_result['message'] = 'Error while ad "' . $sanitized_title . ($is_edit_mode ? '" updating ' : '" adding') . '.';
     }
     return $ajax_result;
 }
开发者ID:gorvic,项目名称:L16,代码行数:18,代码来源:Ad.php

示例7: handlePostQuery

 public static function handlePostQuery(array $sanitized_post_array, $view)
 {
     /* @var $view Smarty */
     // The result of the request
     $ajax_result = array('status' => '', 'message' => '', 'data' => '');
     $is_edit_mode = isset($sanitized_post_array['id']);
     $ad = new Ad($sanitized_post_array);
     $result = $ad->save();
     $sanitized_title = htmlentities($ad->getTitle());
     if ($result) {
         $ajax_result['status'] = 'success';
         $ajax_result['message'] = 'Ad "' . $sanitized_title . '" has been ' . ($is_edit_mode ? '" updated' : '"added') . ' successfully .';
         $view->assign('ad_in_table', $ad);
         $class_name = $ad->getOrganizationFormId() == '1' ? 'organization' : 'individual';
         $ajax_result['data'] = $view->fetch('table_row_' . $class_name . '.tpl.html');
     } else {
         $ajax_result['status'] = 'error';
         $ajax_result['message'] = 'Error while ad "' . $sanitized_title . ($is_edit_mode ? '" updating ' : '" adding') . '.';
     }
     return $ajax_result;
 }
开发者ID:gorvic,项目名称:L17,代码行数:21,代码来源:Ad.php

示例8: actionAdCreate

 /**
  * 广告添加
  *
  */
 public function actionAdCreate()
 {
     $model = new Ad();
     if (isset($_POST['Ad'])) {
         $model->attributes = $_POST['Ad'];
         if ($_FILES['attach']['error'] == UPLOAD_ERR_OK) {
             $upload = new Uploader();
             $upload->uploadFile($_FILES['attach']);
             if ($upload->_error) {
                 $this->message('error', Yii::t('admin', $upload->_error));
                 return;
             }
             $model->attach_file = $upload->_file_name;
             $model->create_time = time();
         }
         if ($model->save()) {
             $this->message('success', Yii::t('admin', 'Add Success'), $this->createUrl('index'));
         }
     }
     $this->render('ad_create', array('model' => $model));
 }
开发者ID:redtreelchao,项目名称:wander-moon,代码行数:25,代码来源:AdController.php

示例9: testTreeWithContainable

 /**
  * testTreeWithContainable method
  *
  * @return void
  */
 public function testTreeWithContainable()
 {
     $this->loadFixtures('Ad', 'Campaign');
     $TestModel = new Ad();
     $TestModel->Behaviors->load('Tree');
     $TestModel->Behaviors->load('Containable');
     $node = $TestModel->findById(2);
     $node['Ad']['parent_id'] = 1;
     $TestModel->save($node);
     $result = $TestModel->getParentNode(array('id' => 2, 'contain' => 'Campaign'));
     $this->assertTrue(array_key_exists('Campaign', $result));
     $result = $TestModel->children(array('id' => 1, 'contain' => 'Campaign'));
     $this->assertTrue(array_key_exists('Campaign', $result[0]));
     $result = $TestModel->getPath(array('id' => 2, 'contain' => 'Campaign'));
     $this->assertTrue(array_key_exists('Campaign', $result[0]));
     $this->assertTrue(array_key_exists('Campaign', $result[1]));
 }
开发者ID:yuuicchan0912,项目名称:sample2,代码行数:22,代码来源:ModelIntegrationTest.php

示例10: catch

        $ad->vintage = Input::getNumber('vintage', 1, 25);
    } catch (Exception $e) {
        $errors[] = $e->getMessage();
    }
    try {
        $ad->price = Input::getString('price', 1, 1000);
    } catch (Exception $e) {
        $errors[] = $e->getMessage();
    }
    try {
        $ad->description = Input::getString('description', 1, 1000);
    } catch (Exception $e) {
        $errors[] = $e->getMessage();
    }
    $ad->post_date = date('Y-m-d h:i');
    $ad->save();
    /*model then handles the save on object*/
}
var_dump($_REQUEST);
?>


<html>
<head>
  <title>Edit an Existing Wineseller Ad</title>
   <meta name="viewport" content="width=device-width, initial-scale=1">
        
            <link rel="stylesheet" href="bootstrap.css">
            <link rel="stylesheet" href="bootstrap.min.css">
            <link rel="stylesheet" href="../css/wineseller.css">
      <meta charset="utf-8">
开发者ID:Wine-Seller,项目名称:WineSeller,代码行数:31,代码来源:adsWineseller.edit.php

示例11: header

require_once '../bootstrap.php';
// $character = Character::where("name", "Ryno");
// var_dump($character);
if (!Auth::checkUser()) {
    header("Location: auth.login.php");
    exit;
}
if (!empty($_POST)) {
    $create_Ad = new Ad();
    $create_Ad->item_name = Input::get('item_name');
    $create_Ad->item_type = Input::get('item_type');
    $create_Ad->date_listed = Input::get('date_listed');
    $create_Ad->price = Input::get('price');
    $create_Ad->description = Input::get('description');
    $create_Ad->item_number = Input::get('item_number');
    $create_Ad->save();
}
?>
<html>
<head>
	<title>WoW Header</title>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
	<link rel="stylesheet" href="/css/main.css">

	
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

	<style>

		.well {
开发者ID:CodeBreakerz,项目名称:adlister.dev,代码行数:31,代码来源:ads.create.php

示例12: actionAdCreate

 /**
  * 广告录入
  *
  */
 public function actionAdCreate()
 {
     parent::_acl('ad_create');
     $model = new Ad();
     if (isset($_POST['Ad'])) {
         $model->attributes = $_POST['Ad'];
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $model->attach_file = $file['pathname'];
         }
         $model->expired_time = intval(strtotime($model->expired_time));
         $model->start_time = intval(strtotime($model->start_time));
         if ($model->save()) {
             XXcache::refresh('_ad');
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入广告,ID:' . $model->id));
             $this->redirect(array('ad'));
         }
     }
     $model->start_time = date('Y-m-d');
     $model->expired_time = date('Y-m-d', time() + 86499);
     $this->render('ad_create', array('model' => $model));
 }
开发者ID:bigbol,项目名称:ziiwo,代码行数:26,代码来源:OperationController.php

示例13: catch

        // Create a person
        $description = Input::getString('description');
    } catch (LengthException $e) {
        // Report any errors
        $errors[] = "Description - " . $e->getMessage();
    } catch (InvalidArgumentException $e) {
        $errors[] = "Description - " . $e->getMessage();
    }
    if ($_FILES) {
        $uploads_directory = 'img/uploads/';
        $filename = $uploads_directory . basename($_FILES['somefile']['name']);
        if (move_uploaded_file($_FILES['somefile']['tmp_name'], $filename)) {
            echo '<p>The file ' . basename($_FILES['somefile']['name']) . ' has been uploaded.</p>';
        } else {
            echo "Sorry, there was an error uploading your file.";
        }
    }
    if (empty($errors)) {
        // $user_id = (int)$_SESSION['user_id'];
        $new_ad = new Ad();
        $new_ad->name = $item;
        $new_ad->price = $price;
        $new_ad->image_url = $filename;
        $new_ad->description = $description;
        $new_ad->postdate = date('Y-m-d h:i');
        // $new_ad->user_id      = $user_id;
        $new_ad->save();
        header("Location: /");
        exit;
    }
}
开发者ID:What-iGot,项目名称:What-iGot-Ad-Lister,代码行数:31,代码来源:add_ad.php

示例14: pageController

function pageController()
{
    session_start();
    if (!Auth::check()) {
        header('Location: /auth/login');
        exit;
    }
    $username = Auth::user();
    $user = User::findUserByUsername($username);
    $errors = array();
    if (!empty($_POST)) {
        $item_name = ValidateAd::getItemName();
        $price = ValidateAd::getPrice();
        $description = ValidateAd::getDescription();
        $contact = ValidateAd::getContact();
        $errors = ValidateAd::getErrors();
        $finfo = new finfo(FILEINFO_MIME_TYPE);
        try {
            $ext = array_search($finfo->file($_FILES['image']['tmp_name']), array('jpg' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif'), true);
            if (false === $ext) {
                throw new RuntimeException('Invalid file format.');
            }
        } catch (RunTimeException $e) {
            $error = $e->getMessage();
            array_push($errors, $error);
        }
        $target = "public/upload_images";
        if (Input::notEmpty('item_name') && Input::notEmpty('price') && Input::notEmpty('description') && Input::notEmpty('contact')) {
            if (empty($errors)) {
                if (array_key_exists('image', $_FILES)) {
                    if ($_FILES["image"]["error"] == UPLOAD_ERR_OK) {
                        $tmp_name = $_FILES["image"]["tmp_name"];
                        $name = $_FILES["image"]["name"];
                        try {
                            if ($name != "jpg" && $name != "png" && $name != "jpeg" && $name != "gif") {
                                throw new RuntimeException('Invalid file format.');
                            }
                        } catch (RunTimeException $e) {
                            $error = $e->getMessage();
                            array_push($errors, $error);
                        }
                        move_uploaded_file($tmp_name, "{$target}/{$name}");
                    }
                } else {
                }
                $ad = new Ad();
                $ad->item_name = $item_name;
                $ad->price = $price;
                $ad->description = $description;
                $ad->contact = $contact;
                $ad->user_id = $user->attributes['id'];
                $ad->image_path = "{$target}/{$name}";
                $ad->save();
                // redirect from add to the users profile so they can see what they added
                header('Location: /users');
                exit;
            }
        }
    }
    return array('username' => $username, 'errors' => $errors);
}
开发者ID:adlisterproject,项目名称:sketchy-b,代码行数:61,代码来源:create.php

示例15: create

 /**
  * @before _secure
  */
 public function create()
 {
     $this->_create();
     $view = $this->getActionView();
     if (RM::type() == 'POST') {
         $img = null;
         // give preference to uploaded image
         $img = $this->_upload('image', 'images', ['extension' => 'jpe?g|gif|bmp|png|tif']);
         if (!$img) {
             $img_url = RM::post("image_url");
             $img = Shared\Utils::downloadImage($img_url);
         }
         if (!$img) {
             return $view->set('message', 'Failed to upload the image');
         }
         $expiry = RM::post('expiry');
         $campaign = new \Ad(['user_id' => RM::post('advert_id'), 'title' => RM::post('title'), 'description' => RM::post('description'), 'org_id' => $this->org->_id, 'url' => RM::post('url'), 'preview_url' => RM::post('preview_url'), 'category' => \Ad::setCategories(RM::post('category')), 'image' => $img, 'type' => RM::post('type', 'article'), 'device' => RM::post('device', ['all']), 'live' => false]);
         $visibility = RM::post('visibility', 'public');
         if ($visibility === "private") {
             $campaign->meta = ['private' => true];
         }
         $permission = RM::post('permission', false);
         if ($permission == "yes") {
             $campaign->meta = ['permission' => true];
         }
         if ($expiry) {
             $campaign->expiry = $expiry;
         }
         try {
             if ($campaign->type === "video") {
                 $url = RM::post('videoUrl');
                 $ytdl = new Downloader($url);
                 $campaign->getMeta()['processing'] = true;
                 $campaign->getMeta()['videoUrl'] = $ytdl->getUrl();
             }
         } catch (\Exception $e) {
             // Invalid URL
             return $view->set("errors", ['videoUrl' => ["Pass a valid youtube video URL"]]);
         }
         if (!$campaign->validate()) {
             return $view->set("errors", $campaign->errors);
         }
         $campaign->save();
         $models = RM::post('model');
         $comm_desc = RM::post('comm_desc');
         $revenue = RM::post('revenue');
         $rate = RM::post('rate');
         $coverage = RM::post('coverage');
         foreach ($models as $key => $value) {
             $commission = new \Commission(['ad_id' => $campaign->_id, 'description' => $comm_desc[$key], 'model' => $value, 'rate' => $this->currency($rate[$key]), 'revenue' => $this->currency($revenue[$key]), 'coverage' => $coverage[$key]]);
             $commission->save();
         }
         Registry::get("session")->set('$flashMessage', 'Campaign Created successfully!!');
         $this->redirect("/campaign/manage.html");
     }
 }
开发者ID:vNative,项目名称:vnative,代码行数:59,代码来源:campaign.php


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