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


PHP CM_Db_Db::getRandId方法代码示例

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


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

示例1: testGetRandId

 public function testGetRandId()
 {
     CM_Db_Db::insert('test', array('foo', 'bar'), array(array('foo1', 'bar1'), array('foo2', 'bar2'), array('foo3', 'bar3')));
     $id = CM_Db_Db::getRandId('test', 'id');
     $this->assertGreaterThanOrEqual(1, $id);
     $id = CM_Db_Db::getRandId('test', 'id', '`id` = 2');
     $this->assertEquals(2, $id);
 }
开发者ID:cargomedia,项目名称:cm,代码行数:8,代码来源:DbTest.php

示例2: testFindByIp

 public function testFindByIp()
 {
     $cityId1 = CM_Db_Db::getRandId('cm_model_location_city', 'id');
     CM_Db_Db::insert('cm_model_location_ip', array('id' => $cityId1, 'level' => CM_Model_Location::LEVEL_CITY, 'ipStart' => 1, 'ipEnd' => 5));
     $cityId2 = CM_Db_Db::getRandId('cm_model_location_city', 'id');
     CM_Db_Db::insert('cm_model_location_ip', array('id' => $cityId2, 'level' => CM_Model_Location::LEVEL_CITY, 'ipStart' => 123456789, 'ipEnd' => 223456789));
     $countryId1 = CM_Db_Db::getRandId('cm_model_location_country', 'id');
     CM_Db_Db::insert('cm_model_location_ip', array('id' => $countryId1, 'level' => CM_Model_Location::LEVEL_COUNTRY, 'ipStart' => 10, 'ipEnd' => 15));
     $countryId2 = CM_Db_Db::getRandId('cm_model_location_country', 'id');
     CM_Db_Db::insert('cm_model_location_ip', array('id' => $countryId2, 'level' => CM_Model_Location::LEVEL_COUNTRY, 'ipStart' => 1234567890, 'ipEnd' => 2234567890));
     $this->assertEquals(new CM_Model_Location(CM_Model_Location::LEVEL_CITY, $cityId1), CM_Model_Location::findByIp(3));
     $this->assertNull(CM_Model_Location::findByIp(6));
     $this->assertEquals(new CM_Model_Location(CM_Model_Location::LEVEL_CITY, $cityId2), CM_Model_Location::findByIp(223456700));
     $this->assertNull(CM_Model_Location::findByIp(223456800));
     $this->assertEquals(new CM_Model_Location(CM_Model_Location::LEVEL_COUNTRY, $countryId1), CM_Model_Location::findByIp(12));
     $this->assertNull(CM_Model_Location::findByIp(16));
     $this->assertEquals(new CM_Model_Location(CM_Model_Location::LEVEL_COUNTRY, $countryId2), CM_Model_Location::findByIp(2234567870));
     $this->assertNull(CM_Model_Location::findByIp(2234567900));
 }
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:19,代码来源:LocationTest.php


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