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


PHP DatabaseConnection::selectRowByID方法代码示例

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


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

示例1: find

 /**
  * Given an ID, finds a character with that ID
  * 
  * @throws StatusCodeException 404 if it does not find the row
  * 
  * @param DatabaseConnection database class instance
  * @param mixed $id ID number, could be a string or an int
  * @return array row of the database with that ID
  */
 public static function find(DatabaseConnection $db, $id)
 {
     $array = $db->selectRowByID('SELECT * FROM characters WHERE id = ?', $id);
     if ($array === NULL) {
         throw new StatusCodeException(404);
     }
     return $array;
 }
开发者ID:rafamalaga86,项目名称:gamerest,代码行数:17,代码来源:Character.php

示例2: testQuery

 public function testQuery()
 {
     require __DIR__ . '/config/database_test.php';
     $db = new DatabaseConnection($host, $database, $user, $password);
     $insert_result = $db->query("INSERT INTO characters (id, name, description, type, dead, stage, hp) \r\n\t\t\tVALUES ('9999', 'Carla', 'The swordmaster of Melee Island', 'pirate', 'false',  '4',  '87');");
     $expected = ['id' => '9999', 'name' => 'Carla', 'description' => 'The swordmaster of Melee Island', 'type' => 'pirate', 'dead' => '0', 'stage' => '4', 'hp' => '87'];
     $actual = $db->selectRowByID("SELECT * FROM characters WHERE id = '9999'");
     $delete_result = $db->query("DELETE FROM characters WHERE id = '9999'");
     $this->assertNotEmpty($actual, 'Character was not inserted properly, selectRowByID could not find it. Check TestDatabaseConnection::selectRowByID() and TestDatabaseConnection::query()');
     $this->assertEquals($expected, $actual, 'Function query not returning expected value. Check TestDatabaseConnection::selectRowByID() and TestDatabaseConnection::query()');
     $this->assertTrue($insert_result, 'Insert query failed. Check TestDatabaseConnection::query()');
     $this->assertTrue($delete_result, 'Delete query failed. Check TestDatabaseConnection::query()');
 }
开发者ID:rafamalaga86,项目名称:gamerest,代码行数:13,代码来源:TestDatabaseConnection.php


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