當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Robots類代碼示例

本文整理匯總了PHP中Robots的典型用法代碼示例。如果您正苦於以下問題:PHP Robots類的具體用法?PHP Robots怎麽用?PHP Robots使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Robots類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _executeTestsNormal

 protected function _executeTestsNormal($di)
 {
     $robot = new Robots();
     $success = $robot->save(array('type' => 'mechanical', 'year' => 2018));
     $this->assertEquals($success, false);
     $this->assertEquals($robot->type, 'mechanical');
     $this->assertEquals($robot->year, 2018);
     $robot = new Robots();
     $robot->assign(array('type' => 'mechanical', 'year' => 2018));
     $this->assertEquals($robot->type, 'mechanical');
     $this->assertEquals($robot->year, 2018);
     //not assigns nonexistent fields
     $robot = new Robots();
     $robot->assign(array('field1' => 'mechanical', 'field2' => 2018));
     $this->assertEquals(empty($robot->field1), true);
     $this->assertEquals(empty($robot->field2), true);
     //white list
     $robot = new Robots();
     $robot->assign(array('type' => 'mechanical', 'year' => 2018), null, array('type'));
     $this->assertEquals($robot->type, 'mechanical');
     $this->assertEquals(empty($robot->year), true);
     //white list
     $robot = new Robots();
     $robot->assign(array('typeFromClient' => 'mechanical', 'yearFromClient' => 2018), array('typeFromClient' => 'type', 'yearFromClient' => 'year'), array('type'));
     $this->assertEquals($robot->type, 'mechanical');
     $this->assertEquals(empty($robot->year), true);
 }
開發者ID:starsw001,項目名稱:cphalcon,代碼行數:27,代碼來源:ModelsMassAssigmentTest.php

示例2: findByRawSql

 public static function findByRawSql($conditions, $params = null)
 {
     // A raw SQL statement
     $sql = "SELECT * FROM robots WHERE {$conditions}";
     // Base model
     $robot = new Robots();
     // Execute the query
     return new Resultset(null, $robot, $robot->getReadConnection()->query($sql, $params));
 }
開發者ID:aodkrisda,項目名稱:phalcon-code,代碼行數:9,代碼來源:phql-855.php

示例3: findByCreateInterval

 public static function findByCreateInterval()
 {
     // A raw SQL statement
     $sql = "SELECT * FROM robots WHERE id > 0";
     // Base model
     $robot = new Robots();
     // Execute the query
     return new Resultset(null, $robot, $robot->getReadConnection()->query($sql));
 }
開發者ID:aodkrisda,項目名稱:phalcon-code,代碼行數:9,代碼來源:phql-849.php

示例4: testTest

 /**
  * @covers itseo\test\Robots::test
  * @todo   Implement testTest().
  */
 public function testTest()
 {
     $dummy_target = "http://www.google.es/";
     $result = $this->object->test($dummy_target);
     $this->assertArrayHasKey("name", $result);
     $this->assertArrayHasKey("score", $result);
     $this->assertArrayHasKey("total_score", $result);
     $this->assertArrayHasKey("result", $result);
     $this->assertEquals("robots", $result['name']);
 }
開發者ID:fran-diaz,項目名稱:itseo,代碼行數:14,代碼來源:RobotsTest.php

示例5: _executeTestsNormal

 protected function _executeTestsNormal($di)
 {
     $robot = new Robots();
     $success = $robot->save(array('type' => 'mechanical', 'year' => 2018));
     $this->assertEquals($success, false);
     $this->assertEquals($robot->type, 'mechanical');
     $this->assertEquals($robot->year, 2018);
     $robot = new Robots();
     $robot->assign(array('type' => 'mechanical', 'year' => 2018));
     $this->assertEquals($robot->type, 'mechanical');
     $this->assertEquals($robot->year, 2018);
 }
開發者ID:racklin,項目名稱:cphalcon,代碼行數:12,代碼來源:ModelsMassAssigmentTest.php

示例6: 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

示例7: testSerialize

 public function testSerialize()
 {
     $this->_prepareDI();
     $robot = Robots::findFirst();
     $serialized = serialize($robot);
     $robot = unserialize($serialized);
     $this->assertTrue($robot->save());
 }
開發者ID:aisuhua,項目名稱:phalcon-php,代碼行數:8,代碼來源:ModelsSerializeTest.php

示例8: findAction

 public function findAction()
 {
     $robots = $this->demoModel->find(array("conditions" => "id >= :id:", "columns" => "id, username,password", "order" => "username DESC", "offset" => 0, "limit" => 10, "group" => "id, username", "bind" => array("id" => 1)));
     dump($robots->toArray());
     exit;
     // 也可以這樣
     $robots = Robots::query()->where("type = :type:")->andWhere("year < 2000")->bind(array("type" => "mechanical"))->order("name")->execute();
     // 單條記錄
     $data = $this->demoModel->findFirst();
 }
開發者ID:xxtime,項目名稱:phalcon,代碼行數:10,代碼來源:DemoController.php

示例9: saveAction

 public function saveAction()
 {
     $this->db->begin();
     $robot = new Robots();
     $robot->name = "WALL·E";
     $robot->created_at = date("Y-m-d");
     if ($robot->save() == false) {
         $this->db->rollback();
         return;
     }
     $robotPart = new RobotParts();
     $robotPart->robots_id = $robot->id;
     $robotPart->type = "head";
     if ($robotPart->save() == false) {
         $this->db->rollback();
         return;
     }
     $this->db->commit();
 }
開發者ID:aodkrisda,項目名稱:phalcon-code,代碼行數:19,代碼來源:models-2364.php

示例10: testCacheResultsetBinding

 public function testCacheResultsetBinding()
 {
     $cache = $this->_getCache();
     $initialId = 0;
     $finalId = 4;
     $cache->save('test-resultset', Robots::find(array('conditions' => 'id > :id1: and id < :id2:', 'bind' => array('id1' => $initialId, 'id2' => $finalId), 'order' => 'id')));
     $this->assertTrue(file_exists(__DIR__ . '/cache/test-resultset'));
     $robots = $cache->get('test-resultset');
     $this->assertEquals(get_class($robots), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $this->assertEquals(count($robots), 3);
     $this->assertEquals($robots->count(), 3);
 }
開發者ID:aisuhua,項目名稱:phalcon-php,代碼行數:12,代碼來源:CacheResultsetTest.php

示例11: testSelectBasic

 /**
  * Tests an image tag with a bare minimum of information passed
  *
  * @author Nikos Dimopoulos <nikos@niden.net>
  * @since  2012-09-09
  */
 public function testSelectBasic()
 {
     // Populate the table
     // Empty the relationship table first
     $this->emptyTable('robots_parts');
     $this->populateTable('robots');
     $this->populateTable('robots_parts');
     $robots = \Robots::find();
     $params = array('some_name', $robots, 'using' => array('id', 'name'));
     $expected = '<select id="some_name" name="some_name">' . PHP_EOL . chr(9) . '<option value="1">Robotina</option>' . PHP_EOL . chr(9) . '<option value="2">Astro Boy</option>' . PHP_EOL . chr(9) . '<option value="3">Terminator</option>' . PHP_EOL . '</select>';
     $actual = PhTag::select($params);
     $this->assertEquals($expected, $actual, sprintf($this->message, 'select basic'));
 }
開發者ID:lisong,項目名稱:cphalcon,代碼行數:19,代碼來源:Model.php

示例12: testSerialize

 public function testSerialize()
 {
     require 'unit-tests/config.db.php';
     if (empty($configMysql)) {
         $this->markTestSkipped('Test skipped');
         return;
     }
     $this->_prepareDI();
     $robot = Robots::findFirst();
     $serialized = serialize($robot);
     $robot = unserialize($serialized);
     $this->assertTrue($robot->save());
 }
開發者ID:boedy,項目名稱:cphalcon,代碼行數:13,代碼來源:ModelsSerializeTest.php

示例13: _executeTestsNormal

 protected function _executeTestsNormal($di)
 {
     $robot = Robots::findFirstById(1);
     $this->assertEquals(get_class($robot), 'Robots');
     $this->assertEquals($robot->id, 1);
     $robot = Robots::findFirstById(2);
     $this->assertEquals(get_class($robot), 'Robots');
     $this->assertEquals($robot->id, 2);
     $robots = Robots::findByType('mechanical');
     $this->assertEquals(count($robots), 2);
     $this->assertEquals($robots[0]->id, 1);
     $number = Robots::countByType('mechanical');
     $this->assertEquals($number, 2);
 }
開發者ID:UqiOnline,項目名稱:cphalcon7,代碼行數:14,代碼來源:ModelsFindersTest.php

示例14: testCacheResultsetNormal

 public function testCacheResultsetNormal()
 {
     require 'unit-tests/config.db.php';
     if (empty($configMysql)) {
         $this->markTestSkipped('Test skipped');
         return;
     }
     $cache = $this->_getCache();
     $cache->save('test-resultset', Robots::find(array('order' => 'id')));
     $this->assertTrue(file_exists('unit-tests/cache/test-resultset'));
     $robots = $cache->get('test-resultset');
     $this->assertEquals(get_class($robots), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $this->assertEquals(count($robots), 3);
     $this->assertEquals($robots->count(), 3);
 }
開發者ID:UqiOnline,項目名稱:cphalcon7,代碼行數:15,代碼來源:CacheResultsetTest.php

示例15: getAnalyzer

 /**
  * Getting crowler
  * @param string $url
  * @return boolean|\Crowler
  */
 public static function getAnalyzer($url)
 {
     // Check is robots allowed
     if (!Robots::robots_allowed($url, Config::$agent_name)) {
         Providers::change_url_status($url, Providers::URLS_TYPE_ROBOTS_NOT_ALLOWED);
         _w('Robots not allowed');
         return false;
     }
     // Create object
     $obj = new ContentAnalyzer($url);
     if (!$obj->getCONTENT_DATA()) {
         Providers::change_url_status($url, Providers::URLS_TYPE_ERROR_NO_DATA);
         return false;
     }
     return $obj;
 }
開發者ID:canaan5,項目名稱:verify-cr,代碼行數:21,代碼來源:contentanalyzer.php


注:本文中的Robots類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。