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


PHP Robots::create方法代码示例

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


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

示例1: create

 public static function create($data)
 {
     $response = new Response();
     try {
         $data = json_decode($data, true);
         /** @var Robots $robot */
         $robot = new Robots();
         $robot->setAttributes($data);
         $response->data = $robot->create();
         $response->status = $response::STATUS_CREATED;
     } catch (Exception $e) {
         $response->setException($e);
     } finally {
         return $response->toArray();
     }
 }
开发者ID:Zhanat87,项目名称:Ariya-House-IT-test,代码行数:16,代码来源:RobotsService.php

示例2: _testCacheDefaultDI

 protected function _testCacheDefaultDI($di)
 {
     $di->set('modelsCache', function () {
         $frontCache = new Phalcon\Cache\Frontend\Data();
         return new Phalcon\Cache\Backend\File($frontCache, array('cacheDir' => 'unit-tests/cache/'));
     }, true);
     //Find
     $robots = Robots::find(array('cache' => array('key' => 'some'), 'order' => 'id'));
     $this->assertEquals(count($robots), 3);
     $this->assertTrue($robots->isFresh());
     $robots = Robots::find(array('cache' => array('key' => 'some'), 'order' => 'id'));
     $this->assertEquals(count($robots), 3);
     $this->assertFalse($robots->isFresh());
     //TODO: I really can't understand why postgresql fails on inserting a simple record
     //The error is "Object not in prerequisite state: 7 ERROR:
     //currval of sequence "robots_id_seq" is not yet defined in this session"
     //Is the ORM working with postgresql, is the database structure incorrect or
     //I'm using the wrong code?
     //Skip this test until someone can shed some light on this
     if (!$di->get("db") instanceof Phalcon\Db\Adapter\Pdo\Postgresql) {
         //Aggregate functions like sum, count, etc
         $robotscount = Robots::count(array('cache' => array('key' => 'some-count')));
         $this->assertEquals($robotscount, 3);
         //Create a temporary robot to test if the count is cached or fresh
         $newrobot = new Robots();
         $newrobot->name = "Not cached robot";
         $newrobot->type = "notcached";
         $newrobot->year = 2014;
         $newrobot->datetime = '2015-03-05 04:16:17';
         $newrobot->text = 'Not cached robot';
         $newrobot->create();
         $robotscount = Robots::count(array('cache' => array('key' => 'some-count')));
         $this->assertEquals($robotscount, 3);
         //Delete the temp robot
         Robots::findFirst("type = 'notcached'")->delete();
     }
 }
开发者ID:lisong,项目名称:cphalcon,代码行数:37,代码来源:ModelsResultsetCacheTest.php

示例3: Robots

<?php

$robot = new Robots();
$robot->type = "mechanical";
$robot->name = "Astro Boy";
$robot->year = 1952;
//This record only must be created
if ($robot->create() == false) {
    echo "Umh, We can't store robots right now: \n";
    foreach ($robot->getMessages() as $message) {
        echo $message, "\n";
    }
} else {
    echo "Great, a new robot was created successfully!";
}
开发者ID:aodkrisda,项目名称:phalcon-code,代码行数:15,代码来源:models-1229.php

示例4: Robots

<?php

//Creating a new robot
$robot = new Robots();
$robot->type = 'mechanical';
$robot->name = 'Astro Boy';
$robot->year = 1952;
$robot->create();
//Passing an array to create
$robot = new Robots();
$robot->create(array('type' => 'mechanical', 'name' => 'Astroy Boy', 'year' => 1952));
开发者ID:aodkrisda,项目名称:phalcon-code,代码行数:11,代码来源:Phalcon_Mvc_Model-632.php

示例5: Robots

<?php

$robot = new Robots();
$robot->name = 'Bender';
$robot->year = 1999;
$robot->created_at = new \Phalcon\Db\RawValue('default');
$robot->create();
开发者ID:aodkrisda,项目名称:phalcon-code,代码行数:7,代码来源:models-1680.php


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