本文整理汇总了PHP中Feedback::findByHash方法的典型用法代码示例。如果您正苦于以下问题:PHP Feedback::findByHash方法的具体用法?PHP Feedback::findByHash怎么用?PHP Feedback::findByHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Feedback
的用法示例。
在下文中一共展示了Feedback::findByHash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHashOldInstance
/**
* Test #17.
* The findByHash function returns an object populated with previous
* values if a hash for a previous instance is given.
* @depends testUpdate
* @depends testHashGetInstance
*/
public function testHashOldInstance()
{
global $testTripId1, $testReferenceId1, $testUserId1;
// create the object and save it
$object = new Feedback($testTripId1, $testReferenceId1, $testUserId1);
$object->setType("like");
$object->setDeleted('N');
$this->assertTrue($object->save());
$this->assertEquals(1, $this->countTestRows());
$old_hash = $object->getHash();
// change values and update the object
$object->setType("off");
$object->setDeleted('Y');
$this->assertTrue($object->save());
$this->assertEquals(2, $this->countTestRows());
$new_hash = $object->getHash();
// read the object from the database and confirm that the old
// values are returned
$object = Feedback::findByHash($old_hash);
$this->assertNotNull($object);
$this->assertEquals($testTripId1, $object->getTripId());
$this->assertEquals($testReferenceId1, $object->getReferenceId());
$this->assertEquals($testUserId1, $object->getUserId());
$this->assertEquals("like", $object->getType());
$this->assertEquals('N', $object->getDeleted());
$this->assertEquals($old_hash, $object->getHash());
// read the new object from the database and confirm that the new
// values are returned
$object = Feedback::findByHash($new_hash);
$this->assertNotNull($object);
$this->assertEquals($testTripId1, $object->getTripId());
$this->assertEquals($testReferenceId1, $object->getReferenceId());
$this->assertEquals($testUserId1, $object->getUserId());
$this->assertEquals("off", $object->getType());
$this->assertEquals('Y', $object->getDeleted());
$this->assertEquals($new_hash, $object->getHash());
}
示例2: dirname
<?php
include_once dirname(__FILE__) . "/../common/common.php";
include_once dirname(__FILE__) . '/../business/AuthB.php';
include_once dirname(__FILE__) . '/../database/Feedback.php';
$auth = new AuthB();
if (!$auth->canSynchFeedback()) {
$response = errorResponse(RESPONSE_UNAUTHORIZED);
} else {
if (isGetMethod()) {
if (isset($_GET['hash'])) {
$hash = $_GET['hash'];
if ($hash === '') {
$response = errorResponse(RESPONSE_BAD_REQUEST);
} else {
$object = Feedback::findByHash($hash);
if ($object === null) {
$response = errorResponse(RESPONSE_NOT_FOUND);
} else {
$response = successResponse();
$response['tripId'] = $object->getTripId();
$response['referenceId'] = $object->getReferenceId();
$response['userId'] = $object->getUserId();
$response['created'] = $object->getCreated();
$response['updated'] = $object->getUpdated();
$response['type'] = $object->getType();
$response['deleted'] = $object->getDeleted();
$response['hash'] = $object->getHash();
}
}
} else {