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


PHP ORM::getLastQuery方法代码示例

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


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

示例1: testMemcaching

 public function testMemcaching()
 {
     ORM::configure('caching', true);
     ORM::configure('caching_driver', 'memcache');
     ORM::addMemcacheServer(array('host' => '127.0.0.1', 'port' => '11211'));
     ORM::forTable('widget')->where('name', 'Fred')->where('age', 17)->findOne();
     ORM::forTable('widget')->where('name', 'Bob')->where('age', 42)->findOne();
     $expected = ORM::getLastQuery();
     // this shouldn't run a query!
     ORM::forTable('widget')->where('name', 'Fred')->where('age', 17)->findOne();
     $this->assertEquals($expected, ORM::getLastQuery());
     Orm::clearCache();
     // this should run now.
     ORM::forTable('widget')->where('name', 'Fred')->where('age', 17)->findOne();
     $this->assertEquals("SELECT * FROM `widget` WHERE `name` = 'Fred' AND `age` = '17' LIMIT 1", Orm::getLastQuery());
 }
开发者ID:kevinsperrine,项目名称:idiorm,代码行数:16,代码来源:IdiormSQLiteTest.php

示例2: testComplexRelationships

 public function testComplexRelationships()
 {
     $book = Model::factory('Book')->findOne(1);
     $authors = $book->authors()->findMany();
     $expected = "SELECT `author`.* FROM `author` JOIN `author_book` ON `author`.`id` = `author_book`.`author_id` WHERE `author_book`.`book_id` = '1'";
     $this->assertEquals($expected, ORM::getLastQuery());
     $book2 = Model::factory('BookTwo')->findOne(1);
     $authors2 = $book2->authors()->findMany();
     $expected = "SELECT `author_two`.* FROM `author_two` JOIN `wrote_the_book` ON `author_two`.`id` = `wrote_the_book`.`custom_author_id` WHERE `wrote_the_book`.`custom_book_id` = '1'";
     $this->assertEquals($expected, ORM::getLastQuery());
     $this->assertEquals($expected, ORM::getLastQuery());
 }
开发者ID:kevinsperrine,项目名称:paris,代码行数:12,代码来源:ModelTest.php


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