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


PHP Sample::create方法代码示例

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


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

示例1: postCreate

 public function postCreate()
 {
     $postData = Input::all();
     $rules = array('userName' => 'required|min:5', 'userEmail' => 'required|email', 'userMobile' => 'required|min:10|numeric', 'userAddress1' => 'required', 'userAddress2' => 'required', 'userPincode' => 'required|min:6|numeric', 'currentUserIdPk' => 'required', 'userCity' => 'required', 'userState' => 'required', 'userId' => 'required|alpha_num', 'userKey' => 'required|min:6|alpha_num', 'cpass' => 'required|min:6|same:userKey', 'userStatus' => 'required', 'prodCode' => 'required');
     $validator = Validator::make($postData, $rules);
     if ($validator->fails()) {
         return Redirect::to('admin/subretailer/add')->withInput()->withErrors($validator);
     } else {
         $input = json_encode(Input::all());
         print_r($input);
         //exit;
         $op = Sample::create($input);
         $output = json_decode($op);
         if (isset($output->status)) {
             if ($output->status == 'failure') {
                 return Redirect::to('admin/subretailer/add')->with('failure', $output->message);
             } else {
                 return Redirect::to('admin/subretailer')->with('sucess', 'registerd successfully');
             }
         } else {
             return Redirect::to('admin/subretailer/add')->with('failure', 'sorry., Please try again later');
         }
     }
     //return Redirect::to('admin/subretailer');
 }
开发者ID:arctic-dev,项目名称:appandukan-php,代码行数:25,代码来源:AdminsubretailerController.php

示例2: postCreate

 public function postCreate()
 {
     $postData = Input::all();
     $rules = array('userName' => 'required|min:5', 'userEmail' => 'required|email', 'userMobile' => 'required|min:10|numeric', 'userAddress1' => 'required', 'userAddress2' => 'required', 'userPincode' => 'required|min:6|numeric', 'currentUserIdPk' => 'required', 'userCity' => 'required', 'userState' => 'required', 'userId' => 'required|alpha_num', 'userKey' => 'required|min:6|alpha_num', 'cpass' => 'required|min:6|same:userKey', 'userStatus' => 'required', 'prodCode' => 'required');
     $validator = Validator::make($postData, $rules);
     if ($validator->fails()) {
         return Redirect::to('franchise/subretailer/add')->withInput()->withErrors($validator);
     } else {
         $data = Input::get('prodCode');
         //print_r($data);
         foreach ($data as $prodcode) {
             $products[] = array('prodCode' => $prodcode, 'prodStatus' => '1');
         }
         $prodCodes = array('products' => $products);
         //print_r(json_encode($prodCodes));
         //exit;
         $input = json_encode(Input::except('prodCode', 'check-all', 'cpass'));
         $finaloutput = array_merge(Input::except('prodCode', 'check-all', 'cpass'), $prodCodes);
         $op1 = json_encode($finaloutput);
         //print_r($op1); exit;
         $op = Sample::create($op1);
         $output = json_decode($op);
         if (isset($output->status)) {
             if ($output->status == 'failure') {
                 return Redirect::to('franchise/subretailer/add')->with('failure', $output->message);
             } else {
                 return Redirect::to('franchise/subretailer')->with('sucess', $output->message);
             }
         } else {
             return Redirect::to('franchise/subretailer/add')->with('failure', 'sorry., Please try again later');
         }
     }
     //return Redirect::to('franchise/subretailer');
 }
开发者ID:arctic-dev,项目名称:appandukan-php,代码行数:34,代码来源:FranchisesubretailerController.php

示例3: run

 public function run()
 {
     /*$faker = Faker::create();
     
     		foreach(range(1, 10) as $index)
     		{
     			Sample::create([
     
     			]);
     		}*/
     Sample::create(['code' => '158-52C-A', 'stock' => 5]);
     Sample::create(['code' => '158-52C-B', 'stock' => 5]);
     Sample::create(['code' => '158-52C-C', 'stock' => 5]);
     Sample::create(['code' => '158-52C-D', 'stock' => 5]);
     Sample::create(['code' => '158-52C-E', 'stock' => 5]);
 }
开发者ID:yanguanglan,项目名称:sz,代码行数:16,代码来源:SamplesTableSeeder.php

示例4: testBehaviorSaveCallbacks

 /**
  * testBehaviorSaveCallbacks method
  *
  * @return void
  */
 public function testBehaviorSaveCallbacks()
 {
     $Sample = new Sample();
     $record = array('Sample' => array('apple_id' => 6, 'name' => 'sample99'));
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'on'));
     $Sample->create();
     $this->assertSame(false, $Sample->save($record));
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'off'));
     $Sample->create();
     $result = $Sample->save($record);
     $expected = $record;
     $expected['Sample']['id'] = $Sample->id;
     $this->assertSame($expected, $result);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'test'));
     $Sample->create();
     $result = $Sample->save($record);
     $expected = $record;
     $expected['Sample']['id'] = $Sample->id;
     $this->assertSame($expected, $result);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'modify'));
     $expected = Hash::insert($record, 'Sample.name', 'sample99 modified before');
     $Sample->create();
     $result = $Sample->save($record);
     $expected['Sample']['id'] = $Sample->id;
     $this->assertSame($expected, $result);
     $Sample->Behaviors->disable('Test');
     $this->assertSame($record, $Sample->save($record));
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'on'));
     $expected = Hash::merge($record, array('Sample' => array('aftersave' => 'modified after on create')));
     $Sample->create();
     $result = $Sample->save($record);
     $expected['Sample']['id'] = $Sample->id;
     $this->assertEquals($expected, $result);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'modify', 'afterSave' => 'modify'));
     $expected = Hash::merge($record, array('Sample' => array('name' => 'sample99 modified before modified after on create')));
     $Sample->create();
     $result = $Sample->save($record);
     $expected['Sample']['id'] = $Sample->id;
     $this->assertSame($expected, $result);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'test'));
     $Sample->create();
     $expected = $record;
     unset($expected['Sample']['name']);
     $result = $Sample->save($record);
     $expected['Sample']['id'] = $Sample->id;
     $this->assertSame($expected, $result);
     $Sample->Behaviors->attach('Test', array('afterSave' => 'test2'));
     $Sample->create();
     $expected = $record;
     $result = $Sample->save($record);
     $expected['Sample']['id'] = $Sample->id;
     $this->assertSame($expected, $result);
     $Sample->Behaviors->attach('Test', array('beforeFind' => 'off', 'afterFind' => 'off'));
     $Sample->recursive = -1;
     $record2 = $Sample->read(null, 1);
     $Sample->Behaviors->attach('Test', array('afterSave' => 'on'));
     $expected = Hash::merge($record2, array('Sample' => array('aftersave' => 'modified after')));
     $Sample->create();
     $this->assertSame($expected, $Sample->save($record2));
     $Sample->Behaviors->attach('Test', array('afterSave' => 'modify'));
     $expected = Hash::merge($record2, array('Sample' => array('name' => 'sample1 modified after')));
     $Sample->create();
     $this->assertSame($expected, $Sample->save($record2));
 }
开发者ID:magooemp,项目名称:eramba,代码行数:69,代码来源:BehaviorCollectionTest.php

示例5: testBehaviorSaveCallbacks

 /**
  * testBehaviorSaveCallbacks method
  *
  * @access public
  * @return void
  */
 function testBehaviorSaveCallbacks()
 {
     $Sample = new Sample();
     $record = array('Sample' => array('apple_id' => 6, 'name' => 'sample99'));
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'on'));
     $Sample->create();
     $this->assertIdentical($Sample->save($record), false);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'off'));
     $Sample->create();
     $this->assertIdentical($Sample->save($record), $record);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'test'));
     $Sample->create();
     $this->assertIdentical($Sample->save($record), $record);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'modify'));
     $expected = Set::insert($record, 'Sample.name', 'sample99 modified before');
     $Sample->create();
     $this->assertIdentical($Sample->save($record), $expected);
     $Sample->Behaviors->disable('Test');
     $this->assertIdentical($Sample->save($record), $record);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'on'));
     $expected = Set::merge($record, array('Sample' => array('aftersave' => 'modified after on create')));
     $Sample->create();
     $this->assertIdentical($Sample->save($record), $expected);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'modify', 'afterSave' => 'modify'));
     $expected = Set::merge($record, array('Sample' => array('name' => 'sample99 modified before modified after on create')));
     $Sample->create();
     $this->assertIdentical($Sample->save($record), $expected);
     $Sample->Behaviors->attach('Test', array('beforeSave' => 'off', 'afterSave' => 'test'));
     $Sample->create();
     $this->assertIdentical($Sample->save($record), $record);
     $Sample->Behaviors->attach('Test', array('afterSave' => 'test2'));
     $Sample->create();
     $this->assertIdentical($Sample->save($record), $record);
     $Sample->Behaviors->attach('Test', array('beforeFind' => 'off', 'afterFind' => 'off'));
     $Sample->recursive = -1;
     $record2 = $Sample->read(null, 1);
     $Sample->Behaviors->attach('Test', array('afterSave' => 'on'));
     $expected = Set::merge($record2, array('Sample' => array('aftersave' => 'modified after')));
     $Sample->create();
     $this->assertIdentical($Sample->save($record2), $expected);
     $Sample->Behaviors->attach('Test', array('afterSave' => 'modify'));
     $expected = Set::merge($record2, array('Sample' => array('name' => 'sample1 modified after')));
     $Sample->create();
     $this->assertIdentical($Sample->save($record2), $expected);
 }
开发者ID:evrard,项目名称:cakephp2x,代码行数:51,代码来源:model_behavior.test.php

示例6: run

 /**
  * @param string $username
  * @param string $session_id
  * @return string
  */
 public static function run($username, $session_id)
 {
     global $session, $user, $transaction;
     $sample_add_role = $session->read_value("SAMPLE_ADD_ROLE");
     $sample_item_retrace = $session->read_value("SAMPLE_ITEM_RETRACE");
     $sample_item_get_array = $session->read_value("SAMPLE_ITEM_GET_ARRAY");
     $sample_item_keywords = $session->read_value("SAMPLE_ITEM_KEYWORDS");
     $sample_item_description = $session->read_value("SAMPLE_ITEM_DESCRIPTION");
     $sample_organ_unit = $session->read_value("SAMPLE_ORGANISATION_UNIT");
     $sample_template = $session->read_value("SAMPLE_TEMPLATE");
     $sample_name = $session->read_value("SAMPLE_NAME");
     $sample_manufacturer = $session->read_value("SAMPLE_MANUFACTURER_ID");
     $sample_manufacturer_name = $session->read_value("SAMPLE_MANUFACTURER_NAME");
     $sample_location = $session->read_value("SAMPLE_LOCATION");
     $sample_expiry = $session->read_value("SAMPLE_EXPIRY");
     $sample_expiry_warning = $session->read_value("SAMPLE_EXPIRY_WARNING");
     $sample_desc = $session->read_value("SAMPLE_DESCRIPTION");
     $sample_template_data_type = $session->read_value("SAMPLE_TEMPLATE_DATA_TYPE");
     $sample_template_data_type_id = $session->read_value("SAMPLE_TEMPLATE_DATA_TYPE_ID");
     $sample_template_data_array = $session->read_value("SAMPLE_TEMPLATE_DATA_ARRAY");
     $transaction_id = $transaction->begin();
     try {
         $sample = new Sample(null);
         $sample->set_template_data($sample_template_data_type, $sample_template_data_type_id, $sample_template_data_array);
         $sample_id = $sample->create($sample_organ_unit, $sample_template, $sample_name, $sample_manufacturer, $sample_location, $sample_desc, null, $sample_expiry, $sample_expiry_warning);
         if ($sample_add_role == "item" or $sample_add_role == "item_parent") {
             // Special Parent Sample Case
             if ($sample_add_role == "item_parent") {
                 $parent_sample = new Sample($sample_item_get_array['sample_id']);
                 $sample_item_get_array['sample_id'] = $sample_id;
                 $sample_item_get_array['parent_sample'] = "1";
                 $event_item_id = $parent_sample->get_item_id();
             } else {
                 $event_item_id = $sample->get_item_id();
             }
             $post_array = array();
             $post_array['keywords'] = $sample_item_keywords;
             $post_array['description'] = $sample_item_description;
             $item_add_event = new ItemAddEvent($event_item_id, $sample_item_get_array, $post_array, true, "sample");
             $event_handler = new EventHandler($item_add_event);
             if ($event_handler->get_success() == true) {
                 // Nothing
             }
         }
     } catch (BaseException $e) {
         if ($transaction_id != null) {
             $transaction->rollback($transaction_id);
         }
         throw $e;
     }
     $session->delete_value("SAMPLE_ADD_ROLE");
     $session->delete_value("SAMPLE_ADD_ITEM_HOLDER_CLASS");
     $session->delete_value("SAMPLE_ADD_ITEM_HOLDER_ID");
     $session->delete_value("SAMPLE_ITEM_RETRACE");
     $session->delete_value("SAMPLE_ITEM_GET_ARRAY");
     $session->delete_value("SAMPLE_ITEM_KEYWORDS");
     $session->delete_value("SAMPLE_ITEM_DESCRIPTION");
     $session->delete_value("SAMPLE_ITEM_TYPE_ARRAY");
     $session->delete_value("SAMPLE_ORGANISATION_UNIT");
     $session->delete_value("SAMPLE_TEMPLATE");
     $session->delete_value("SAMPLE_NAME");
     $session->delete_value("SAMPLE_MANUFACTURER_ID");
     $session->delete_value("SAMPLE_MANUFACTURER_NAME");
     $session->delete_value("SAMPLE_LOCATION");
     $session->delete_value("SAMPLE_EXPIRY");
     $session->delete_value("SAMPLE_EXPIRY_WARNING");
     $session->delete_value("SAMPLE_DESCRIPTION");
     $session->delete_value("SAMPLE_TEMPLATE_DATA_TYPE");
     $session->delete_value("SAMPLE_TEMPLATE_DATA_TYPE_ID");
     $session->delete_value("SAMPLE_TEMPLATE_DATA_ARRAY");
     if ($sample_add_role == "item" or $sample_add_role == "item_parent") {
         if ($transaction_id != null) {
             $transaction->commit($transaction_id);
         }
         if ($sample_item_retrace) {
             $params = http_build_query(Retrace::resolve_retrace_string($sample_item_retrace), '', '&');
             return "index.php?" . $params;
         } else {
             $paramquery['username'] = $username;
             $paramquery['session_id'] = $session_id;
             $paramquery['nav'] = "home";
             $params = http_build_query($paramquery, '', '&');
             return "index.php?" . $params;
         }
     } else {
         if ($transaction_id != null) {
             $transaction->commit($transaction_id);
         }
         $paramquery = array();
         $paramquery['username'] = $username;
         $paramquery['session_id'] = $session_id;
         $paramquery['nav'] = "sample";
         $paramquery['run'] = "detail";
         $paramquery['sample_id'] = $sample_id;
         $params = http_build_query($paramquery, '', '&');
//.........这里部分代码省略.........
开发者ID:suxinde2009,项目名称:www,代码行数:101,代码来源:sample_create.ajax.php


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