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


PHP Brand::loadOne方法代码示例

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


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

示例1: testForTest

 public function testForTest()
 {
     TranslateAbility::setLanguageId(1);
     $brand = new \Brand(array('title' => 'Apple'));
     $this->assertEquals('Apple', $brand->title, 'Accessor after creating');
     $brand->save();
     $this->assertEquals('Apple', $brand->title, 'Accessor after saving');
     $brand = \Brand::loadOne(1);
     $this->assertEquals('Apple', $brand->title, 'Accessor after loading');
     $this->assertEquals(array('id_language' => 1, 'id_object' => 1, 'title' => 'Apple'), QC::create('brands_translate')->executeOne(), 'Data stored in DB after saving');
     TranslateAbility::setLanguageId(2);
     $brand->title = 'Яблоко';
     $brand->save();
     $this->assertEquals('Яблоко', $brand->title, 'Accessor after loading');
     $this->assertEquals(array('id_language' => 2, 'id_object' => 1, 'title' => 'Яблоко'), QC::create('brands_translate')->where('id_language = :d', 2)->executeOne(), 'Data stored in DB after saving');
     $brand->loadTranslation(1);
     $this->assertEquals('Apple', $brand->title, 'loadTranslation works');
     $this->assertEquals(array('id' => 1, 'id_object' => 1, 'id_language' => 2, 'title' => 'Яблоко'), $brand->getTranslationForLanguage(2), 'getTranslationForLanguage');
     TranslateAbility::setLanguageId(1);
     $brand2 = new \Brand();
     $brand2->title = 'Samsung';
     $brand2->save();
     $brand2->loadTranslation(2);
     $this->assertEmpty($brand2->title, 'Empty data for not translated item');
     $brands = \Brand::loadList();
     $this->assertEquals(array('Apple', 'Samsung'), $brands->getFieldArray('title'), 'Loaded two translated items');
     $brands->loadTranslation(2);
     $this->assertEquals(array('Яблоко', null), $brands->getFieldArray('title'), 'Loaded two not fully translated items');
     $this->assertEquals(array(1 => array('id' => 1, 'id_object' => 1, 'id_language' => 1, 'title' => 'Apple'), 2 => array('id' => 1, 'id_object' => 1, 'id_language' => 2, 'title' => 'Яблоко')), $brand->getAllTranslations(), 'getAllTranslations()');
 }
开发者ID:solve,项目名称:database,代码行数:30,代码来源:ModelAbilityTranslateTest.php

示例2: testBasic

 public function testBasic()
 {
     $brand = new \Brand(array('title' => 'Apple'));
     $brand->save();
     $brand = \Brand::loadOne(1);
     $brand->attachFileFromPath('logo', __DIR__ . '/../README.md');
     $this->assertEquals('01/1/logo/README.md', $brand->logo[0]['link'], 'original file name');
     $brand->attachFileFromPath('logo', __DIR__ . '/../README.md');
     $this->assertEquals('01/1/logo/README_1.md', $brand->logo[1]['link'], 'duplicate of original file name');
     $brand = \Brand::loadOne(1);
     $this->assertEquals(2, count($brand->logo), 'loaded two files on demand');
     $brand->delete();
     $this->assertEmpty(FSService::getInstance()->in(__DIR__ . '/upload/01/')->find(), 'No files left after deleting');
     $brand = new \Brand(array('title' => 'Apple'));
     $_FILES['logo'] = array('tmp_name' => __DIR__ . '/../README.md', 'name' => 'readme.md');
     $_FILES['info_file'] = array('tmp_name' => __DIR__ . '/../README.md', 'name' => 'readme.md');
     $brand->setFieldNameForAlias('info', 'info_file');
     $brand->save();
     $this->assertEquals(2, count(FSService::getInstance()->in(__DIR__ . '/upload/02/2')->find()), 'Two files saved to object');
     $brand->delete();
     $brand = new \Brand(array('title' => 'Apple'));
     $_FILES['logo'] = array('tmp_name' => __DIR__ . '/../README.md', 'name' => 'readme.md');
     $_FILES['info'] = array('tmp_name' => __DIR__ . '/../README.md', 'name' => 'readme.md');
     $brand->skipFileAliasForSave('logo');
     $brand->save();
     $this->assertEquals(1, count(FSService::getInstance()->in(__DIR__ . '/upload/03/3')->find()), 'Skipped logo');
     $brand->delete();
 }
开发者ID:solve,项目名称:database,代码行数:28,代码来源:ModelAbilityFilesTest.php


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