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


PHP Apple类代码示例

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


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

示例1: testGenerateFindList

 /**
  * test find('list') method
  *
  * @return void
  */
 public function testGenerateFindList()
 {
     $this->loadFixtures('Article', 'Apple', 'Post', 'Author', 'User', 'Comment');
     $TestModel = new Article();
     $TestModel->displayField = 'title';
     $result = $TestModel->find('list', array('order' => 'Article.title ASC'));
     $expected = array(1 => 'First Article', 2 => 'Second Article', 3 => 'Third Article');
     $this->assertEquals($expected, $result);
     $db = ConnectionManager::getDataSource('test');
     if ($db instanceof Mysql) {
         $result = $TestModel->find('list', array('order' => array('FIELD(Article.id, 3, 2) ASC', 'Article.title ASC')));
         $expected = array(1 => 'First Article', 3 => 'Third Article', 2 => 'Second Article');
         $this->assertEquals($expected, $result);
     }
     $result = Hash::combine($TestModel->find('all', array('order' => 'Article.title ASC', 'fields' => array('id', 'title'))), '{n}.Article.id', '{n}.Article.title');
     $expected = array(1 => 'First Article', 2 => 'Second Article', 3 => 'Third Article');
     $this->assertEquals($expected, $result);
     $result = Hash::combine($TestModel->find('all', array('order' => 'Article.title ASC')), '{n}.Article.id', '{n}.Article');
     $expected = array(1 => array('id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'), 2 => array('id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'), 3 => array('id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'));
     $this->assertEquals($expected, $result);
     $result = Hash::combine($TestModel->find('all', array('order' => 'Article.title ASC')), '{n}.Article.id', '{n}.Article', '{n}.Article.user_id');
     $expected = array(1 => array(1 => array('id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'), 3 => array('id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31')), 3 => array(2 => array('id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31')));
     $this->assertEquals($expected, $result);
     $result = Hash::combine($TestModel->find('all', array('order' => 'Article.title ASC', 'fields' => array('id', 'title', 'user_id'))), '{n}.Article.id', '{n}.Article.title', '{n}.Article.user_id');
     $expected = array(1 => array(1 => 'First Article', 3 => 'Third Article'), 3 => array(2 => 'Second Article'));
     $this->assertEquals($expected, $result);
     $TestModel = new Apple();
     $expected = array(1 => 'Red Apple 1', 2 => 'Bright Red Apple', 3 => 'green blue', 4 => 'Test Name', 5 => 'Blue Green', 6 => 'My new apple', 7 => 'Some odd color');
     $this->assertEquals($expected, $TestModel->find('list'));
     $this->assertEquals($expected, $TestModel->Parent->find('list'));
     $TestModel = new Post();
     $result = $TestModel->find('list', array('fields' => 'Post.title'));
     $expected = array(1 => 'First Post', 2 => 'Second Post', 3 => 'Third Post');
     $this->assertEquals($expected, $result);
     $result = $TestModel->find('list', array('fields' => 'title'));
     $expected = array(1 => 'First Post', 2 => 'Second Post', 3 => 'Third Post');
     $this->assertEquals($expected, $result);
     $result = $TestModel->find('list', array('fields' => array('title', 'id')));
     $expected = array('First Post' => '1', 'Second Post' => '2', 'Third Post' => '3');
     $this->assertEquals($expected, $result);
     $result = $TestModel->find('list', array('fields' => array('title', 'id', 'created')));
     $expected = array('2007-03-18 10:39:23' => array('First Post' => '1'), '2007-03-18 10:41:23' => array('Second Post' => '2'), '2007-03-18 10:43:23' => array('Third Post' => '3'));
     $this->assertEquals($expected, $result);
     $result = $TestModel->find('list', array('fields' => array('Post.body')));
     $expected = array(1 => 'First Post Body', 2 => 'Second Post Body', 3 => 'Third Post Body');
     $this->assertEquals($expected, $result);
     $result = $TestModel->find('list', array('fields' => array('Post.title', 'Post.body')));
     $expected = array('First Post' => 'First Post Body', 'Second Post' => 'Second Post Body', 'Third Post' => 'Third Post Body');
     $this->assertEquals($expected, $result);
     $result = $TestModel->find('list', array('fields' => array('Post.id', 'Post.title', 'Author.user'), 'recursive' => 1));
     $expected = array('mariano' => array(1 => 'First Post', 3 => 'Third Post'), 'larry' => array(2 => 'Second Post'));
     $this->assertEquals($expected, $result);
     $TestModel = new User();
     $result = $TestModel->find('list', array('fields' => array('User.user', 'User.password')));
     $expected = array('mariano' => '5f4dcc3b5aa765d61d8327deb882cf99', 'nate' => '5f4dcc3b5aa765d61d8327deb882cf99', 'larry' => '5f4dcc3b5aa765d61d8327deb882cf99', 'garrett' => '5f4dcc3b5aa765d61d8327deb882cf99');
     $this->assertEquals($expected, $result);
     $TestModel = new ModifiedAuthor();
     $result = $TestModel->find('list', array('fields' => array('Author.id', 'Author.user')));
     $expected = array(1 => 'mariano (CakePHP)', 2 => 'nate (CakePHP)', 3 => 'larry (CakePHP)', 4 => 'garrett (CakePHP)');
     $this->assertEquals($expected, $result);
     $TestModel = new Article();
     $TestModel->displayField = 'title';
     $result = $TestModel->find('list', array('conditions' => array('User.user' => 'mariano'), 'recursive' => 0));
     $expected = array(1 => 'First Article', 3 => 'Third Article');
     $this->assertEquals($expected, $result);
 }
开发者ID:TerrasAppSolutions,项目名称:seeg-mapbiomas-workspace,代码行数:71,代码来源:ModelReadTest.php

示例2: testBehaviorMethodDispatchingWithData

 /**
  * testBehaviorMethodDispatchingWithData method
  *
  * @return void
  */
 public function testBehaviorMethodDispatchingWithData()
 {
     $Apple = new Apple();
     $Apple->Behaviors->attach('Test');
     $Apple->set('field', 'value');
     $this->assertTrue($Apple->testData());
     $this->assertTrue($Apple->data['Apple']['field_2']);
     $this->assertTrue($Apple->testData('one', 'two', 'three', 'four', 'five', 'six'));
 }
开发者ID:magooemp,项目名称:eramba,代码行数:14,代码来源:BehaviorCollectionTest.php

示例3: testTablePrefixSwitching

 /**
  * testTablePrefixSwitching method
  *
  * @access public
  * @return void
  */
 function testTablePrefixSwitching()
 {
     ConnectionManager::create('database1', array_merge($this->db->config, array('prefix' => 'aaa_')));
     ConnectionManager::create('database2', array_merge($this->db->config, array('prefix' => 'bbb_')));
     $db1 = ConnectionManager::getDataSource('database1');
     $db2 = ConnectionManager::getDataSource('database2');
     $TestModel = new Apple();
     $TestModel->setDataSource('database1');
     $this->assertEqual($this->db->fullTableName($TestModel, false), 'aaa_apples');
     $this->assertEqual($db1->fullTableName($TestModel, false), 'aaa_apples');
     $this->assertEqual($db2->fullTableName($TestModel, false), 'aaa_apples');
     $TestModel->setDataSource('database2');
     $this->assertEqual($this->db->fullTableName($TestModel, false), 'bbb_apples');
     $this->assertEqual($db1->fullTableName($TestModel, false), 'bbb_apples');
     $this->assertEqual($db2->fullTableName($TestModel, false), 'bbb_apples');
     $TestModel = new Apple();
     $TestModel->tablePrefix = 'custom_';
     $this->assertEqual($this->db->fullTableName($TestModel, false), 'custom_apples');
     $TestModel->setDataSource('database1');
     $this->assertEqual($this->db->fullTableName($TestModel, false), 'custom_apples');
     $this->assertEqual($db1->fullTableName($TestModel, false), 'custom_apples');
     $TestModel = new Apple();
     $TestModel->setDataSource('database1');
     $this->assertEqual($this->db->fullTableName($TestModel, false), 'aaa_apples');
     $TestModel->tablePrefix = '';
     $TestModel->setDataSource('database2');
     $this->assertEqual($db2->fullTableName($TestModel, false), 'apples');
     $this->assertEqual($db1->fullTableName($TestModel, false), 'apples');
     $TestModel->tablePrefix = null;
     $TestModel->setDataSource('database1');
     $this->assertEqual($db2->fullTableName($TestModel, false), 'aaa_apples');
     $this->assertEqual($db1->fullTableName($TestModel, false), 'aaa_apples');
     $TestModel->tablePrefix = false;
     $TestModel->setDataSource('database2');
     $this->assertEqual($db2->fullTableName($TestModel, false), 'apples');
     $this->assertEqual($db1->fullTableName($TestModel, false), 'apples');
 }
开发者ID:robsawyer,项目名称:PMT,代码行数:43,代码来源:model_integration.test.php

示例4: testBehaviorMethodDispatchingWithData

 /**
  * testBehaviorMethodDispatchingWithData method
  *
  * @access public
  * @return void
  */
 function testBehaviorMethodDispatchingWithData()
 {
     $Apple = new Apple();
     $Apple->Behaviors->attach('Test');
     $Apple->set('field', 'value');
     $this->assertTrue($Apple->testData());
     $this->assertTrue($Apple->data['Apple']['field_2']);
 }
开发者ID:masayukiando,项目名称:googlemap-search_ActionScript3.0,代码行数:14,代码来源:behavior.test.php

示例5: testCallingParentOnStatics

 public function testCallingParentOnStatics()
 {
     $this->assertEquals('Fruit', Fruit::getName());
     $this->assertEquals('Fruit: Apple', Apple::getName());
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:5,代码来源:PhpTest.php

示例6: testTablePrefixSwitching

 /**
  * testTablePrefixSwitching method
  *
  * @return void
  */
 public function testTablePrefixSwitching()
 {
     ConnectionManager::create('database1', array_merge($this->db->config, array('prefix' => 'aaa_')));
     ConnectionManager::create('database2', array_merge($this->db->config, array('prefix' => 'bbb_')));
     $db1 = ConnectionManager::getDataSource('database1');
     $db2 = ConnectionManager::getDataSource('database2');
     $TestModel = new Apple();
     $TestModel->setDataSource('database1');
     $this->assertContains('aaa_apples', $this->db->fullTableName($TestModel));
     $this->assertContains('aaa_apples', $db1->fullTableName($TestModel));
     $this->assertContains('aaa_apples', $db2->fullTableName($TestModel));
     $TestModel->setDataSource('database2');
     $this->assertContains('bbb_apples', $this->db->fullTableName($TestModel));
     $this->assertContains('bbb_apples', $db1->fullTableName($TestModel));
     $this->assertContains('bbb_apples', $db2->fullTableName($TestModel));
     $TestModel = new Apple();
     $TestModel->tablePrefix = 'custom_';
     $this->assertContains('custom_apples', $this->db->fullTableName($TestModel));
     $TestModel->setDataSource('database1');
     $this->assertContains('custom_apples', $this->db->fullTableName($TestModel));
     $this->assertContains('custom_apples', $db1->fullTableName($TestModel));
     $TestModel = new Apple();
     $TestModel->setDataSource('database1');
     $this->assertContains('aaa_apples', $this->db->fullTableName($TestModel));
     $TestModel->tablePrefix = '';
     $TestModel->setDataSource('database2');
     $this->assertContains('apples', $db2->fullTableName($TestModel));
     $this->assertContains('apples', $db1->fullTableName($TestModel));
     $TestModel->tablePrefix = NULL;
     $TestModel->setDataSource('database1');
     $this->assertContains('aaa_apples', $db2->fullTableName($TestModel));
     $this->assertContains('aaa_apples', $db1->fullTableName($TestModel));
     $TestModel->tablePrefix = FALSE;
     $TestModel->setDataSource('database2');
     $this->assertContains('apples', $db2->fullTableName($TestModel));
     $this->assertContains('apples', $db1->fullTableName($TestModel));
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:42,代码来源:ModelIntegrationTest.php

示例7: remove

		public function remove($appleID = null)
		{
			// Confirm and Delete an Tofu
			$this->apple = Apple::find($appleID);
			$this->apple->remove($_POST['apple']);
		}
开发者ID:nickbarth,项目名称:PHP-Tofu,代码行数:6,代码来源:apples.php

示例8: declare

<?php

declare (strict_types=1);
class Apple
{
    function getMyApple() : self
    {
        return new Apple();
    }
}
$apple = new Apple();
var_dump($apple->getMyApple());
// This will fail
function thisFunctionWillFail() : self
{
}
var_dump(thisFunctionWillFail());
开发者ID:jithinjose2,项目名称:php7-returntype,代码行数:17,代码来源:self.php


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