本文整理汇总了PHP中Robots类的典型用法代码示例。如果您正苦于以下问题:PHP Robots类的具体用法?PHP Robots怎么用?PHP Robots使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Robots类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 <[email protected]>
* @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
示例16: testJsonSerialize
public function testJsonSerialize()
{
require 'unit-tests/config.db.php';
if (empty($configMysql)) {
$this->markTestSkipped('Test skipped');
return;
}
$di = $this->_getDI();
// Single model object json serialization
$robot = Robots::findFirst();
$json = json_encode($robot);
$this->assertTrue(is_string($json));
$this->assertTrue(strlen($json) > 10);
// make sure result is not "{ }"
$array = json_decode($json, true);
$this->assertEquals($robot->toArray(), $array);
// Result-set serialization
$robots = Robots::find();
$json = json_encode($robots);
$this->assertTrue(is_string($json));
$this->assertTrue(strlen($json) > 50);
// make sure result is not "{ }"
$array = json_decode($json, true);
$this->assertEquals($robots->toArray(), $array);
// Single row serialization
$result = $di->get('modelsManager')->executeQuery('SELECT id FROM Robots LIMIT 1');
$this->assertEquals(get_class($result), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
foreach ($result as $row) {
$this->assertEquals(get_class($row), 'Phalcon\\Mvc\\Model\\Row');
$this->assertEquals($row->id, $robot->id);
$json = json_encode($row);
$this->assertTrue(is_string($json));
$this->assertTrue(strlen($json) > 5);
// make sure result is not "{ }"
$array = json_decode($json, true);
$this->assertEquals($row->toArray(), $array);
}
}
开发者ID:Jurigag,项目名称:cphalcon,代码行数:38,代码来源:ModelsSerializeTest.php
示例17: _executeTestsNormal
protected function _executeTestsNormal($di)
{
$this->_prepareDb($di->getShared('db'));
//Count tests
$this->assertEquals(People::count(), Personas::count());
$params = array();
$this->assertEquals(People::count($params), Personas::count($params));
$params = array("estado='I'");
$this->assertEquals(People::count($params), Personas::count($params));
$params = "estado='I'";
$this->assertEquals(People::count($params), Personas::count($params));
$params = array("conditions" => "estado='I'");
$this->assertEquals(People::count($params), Personas::count($params));
//Find first
$people = People::findFirst();
$this->assertTrue(is_object($people));
$this->assertEquals(get_class($people), 'People');
$persona = Personas::findFirst();
$this->assertEquals($people->nombres, $persona->nombres);
$this->assertEquals($people->estado, $persona->estado);
$people = People::findFirst("estado='I'");
$this->assertTrue(is_object($people));
$persona = Personas::findFirst("estado='I'");
$this->assertTrue(is_object($persona));
$this->assertEquals($people->nombres, $persona->nombres);
$this->assertEquals($people->estado, $persona->estado);
$people = People::findFirst(array("estado='I'"));
$persona = Personas::findFirst(array("estado='I'"));
$this->assertEquals($people->nombres, $persona->nombres);
$this->assertEquals($people->estado, $persona->estado);
$params = array("conditions" => "estado='I'");
$people = People::findFirst($params);
$persona = Personas::findFirst($params);
$this->assertEquals($people->nombres, $persona->nombres);
$this->assertEquals($people->estado, $persona->estado);
$params = array("conditions" => "estado='A'", "order" => "nombres");
$people = People::findFirst($params);
$persona = Personas::findFirst($params);
$this->assertEquals($people->nombres, $persona->nombres);
$this->assertEquals($people->estado, $persona->estado);
$params = array("estado='A'", "order" => "nombres DESC", "limit" => 30);
$people = People::findFirst($params);
$persona = Personas::findFirst($params);
$this->assertEquals($people->nombres, $persona->nombres);
$this->assertEquals($people->estado, $persona->estado);
$params = array("estado=?1", "bind" => array(1 => 'A'), "order" => "nombres DESC", "limit" => 30);
$people = People::findFirst($params);
$persona = Personas::findFirst($params);
$this->assertEquals($people->nombres, $persona->nombres);
$this->assertEquals($people->estado, $persona->estado);
$params = array("estado=:estado:", "bind" => array("estado" => 'A'), "order" => "nombres DESC", "limit" => 30);
$people = People::findFirst($params);
$persona = Personas::findFirst($params);
$this->assertEquals($people->nombres, $persona->nombres);
$this->assertEquals($people->estado, $persona->estado);
$robot = Robots::findFirst(1);
$this->assertEquals(get_class($robot), 'Robots');
//Find tests
$personas = Personas::find();
$people = People::find();
$this->assertEquals(count($personas), count($people));
$personas = Personas::find("estado='I'");
$people = People::find("estado='I'");
$this->assertEquals(count($personas), count($people));
$personas = Personas::find(array("estado='I'"));
$people = People::find(array("estado='I'"));
$this->assertEquals(count($personas), count($people));
$personas = Personas::find(array("estado='A'", "order" => "nombres"));
$people = People::find(array("estado='A'", "order" => "nombres"));
$this->assertEquals(count($personas), count($people));
$personas = Personas::find(array("estado='A'", "order" => "nombres", "limit" => 100));
$people = People::find(array("estado='A'", "order" => "nombres", "limit" => 100));
$this->assertEquals(count($personas), count($people));
$params = array("estado=?1", "bind" => array(1 => "A"), "order" => "nombres", "limit" => 100);
$personas = Personas::find($params);
$people = People::find($params);
$this->assertEquals(count($personas), count($people));
$params = array("estado=:estado:", "bind" => array("estado" => "A"), "order" => "nombres", "limit" => 100);
$personas = Personas::find($params);
$people = People::find($params);
$this->assertEquals(count($personas), count($people));
$number = 0;
$peoples = Personas::find(array("conditions" => "estado='A'", "order" => "nombres", "limit" => 20));
foreach ($peoples as $people) {
$number++;
}
$this->assertEquals($number, 20);
$persona = new Personas($di);
$persona->cedula = 'CELL' . mt_rand(0, 999999);
$this->assertFalse($persona->save());
//Messages
$this->assertEquals(count($persona->getMessages()), 4);
$messages = array(0 => ModelMessage::__set_state(array('_type' => 'PresenceOf', '_message' => 'tipo_documento_id is required', '_field' => 'tipo_documento_id')), 1 => ModelMessage::__set_state(array('_type' => 'PresenceOf', '_message' => 'nombres is required', '_field' => 'nombres')), 2 => ModelMessage::__set_state(array('_type' => 'PresenceOf', '_message' => 'cupo is required', '_field' => 'cupo')), 3 => ModelMessage::__set_state(array('_type' => 'PresenceOf', '_message' => 'estado is required', '_field' => 'estado')));
$this->assertEquals($persona->getMessages(), $messages);
//Save
$persona = new Personas($di);
$persona->cedula = 'CELL' . mt_rand(0, 999999);
$persona->tipo_documento_id = 1;
$persona->nombres = 'LOST';
$persona->telefono = '1';
//.........这里部分代码省略.........
开发者ID:aisuhua,项目名称:phalcon-php,代码行数:101,代码来源:ModelsTest.php
示例18: RobotParts
<?php
$robotPart = new RobotParts();
$robotPart->type = "head";
$robot = new Robots();
$robot->name = "WALL·E";
$robot->created_at = date("Y-m-d");
$robot->robotPart = $robotPart;
$robot->save();
//Creates an implicit transaction to store both records
开发者ID:aodkrisda,项目名称:phalcon-code,代码行数:10,代码来源:models-2124.php
示例19: testMetadataFiles
public function testMetadataFiles()
{
$di = $this->_getDI();
$di->set('modelsMetadata', function () {
return new Phalcon\Mvc\Model\Metadata\Files(array('metaDataDir' => 'unit-tests/cache/'));
});
@unlink('unit-tests/cache/meta-robots-robots.php');
@unlink('unit-tests/cache/map-robots.php');
$metaData = $di->getShared('modelsMetadata');
$metaData->reset();
$this->assertTrue($metaData->isEmpty());
Robots::findFirst();
$this->assertEquals(require 'unit-tests/cache/meta-robots-robots.php', $this->_data['meta-robots-robots']);
$this->assertEquals(require 'unit-tests/cache/map-robots.php', $this->_data['map-robots']);
$this->assertFalse($metaData->isEmpty());
Robots::findFirst();
}
开发者ID:racklin,项目名称:cphalcon,代码行数:17,代码来源:ModelsMetadataAdaptersTest.php
示例20: _executeTestsNormal
protected function _executeTestsNormal($di)
{
$number = 0;
$robots = Robots::find();
foreach ($robots as $robot) {
$this->assertTrue(is_object($robot));
$this->assertEquals(get_class($robot), 'Robots');
$number++;
}
$robots->setHydrateMode(Phalcon\Mvc\Model\Resultset::HYDRATE_RECORDS);
foreach ($robots as $robot) {
$this->assertTrue(is_object($robot));
$this->assertEquals(get_class($robot), 'Robots');
$number++;
}
$robots->setHydrateMode(Phalcon\Mvc\Model\Resultset::HYDRATE_ARRAYS);
foreach ($robots as $robot) {
$this->assertTrue(is_array($robot));
$this->assertEquals(count($robot), 4);
$number++;
}
$robots->setHydrateMode(Phalcon\Mvc\Model\Resultset::HYDRATE_OBJECTS);
foreach ($robots as $robot) {
$this->assertTrue(is_object($robot));
$this->assertEquals(get_class($robot), 'stdClass');
$number++;
}
$this->assertEquals($number, 12);
$number = 0;
$people = People::find(array('limit' => 33));
foreach ($people as $person) {
$this->assertTrue(is_object($person));
$this->assertEquals(get_class($person), 'People');
$number++;
}
$people->setHydrateMode(Phalcon\Mvc\Model\Resultset::HYDRATE_RECORDS);
foreach ($people as $person) {
$this->assertTrue(is_object($person));
$this->assertEquals(get_class($person), 'People');
$number++;
}
$people->setHydrateMode(Phalcon\Mvc\Model\Resultset::HYDRATE_ARRAYS);
foreach ($people as $person) {
$this->assertTrue(is_array($person));
$number++;
}
$people->setHydrateMode(Phalcon\Mvc\Model\Resultset::HYDRATE_OBJECTS);
foreach ($people as $person) {
$this->assertTrue(is_object($person));
$this->assertEquals(get_class($person), 'stdClass');
$number++;
}
$this->assertEquals($number, 33 * 4);
}
开发者ID:racklin,项目名称:cphalcon,代码行数:54,代码来源:ModelsHydrationTest.php
注:本文中的Robots类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论