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


PHP Media::getCreated方法代码示例

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


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

示例1: json_encode

    }
    if ($tripId === '' || $mediaId === '' && $list === '') {
        $response = errorResponse(RESPONSE_BAD_REQUEST);
    } else {
        if ($mediaId !== '') {
            $object = new Media($tripId, $mediaId);
            if ($object->getCreated() === null) {
                $response = errorResponse(RESPONSE_NOT_FOUND);
            } else {
                $response = successResponse();
                $response = fillMediaItem($response, $object);
            }
        } else {
            $array = split(',', $list);
            $resultArray = array();
            $resultArrayCount = 0;
            for ($i = 0; $i < count($array); $i++) {
                $object = new Media($tripId, $array[$i]);
                if ($object->getCreated() !== null) {
                    $item = array();
                    $item = fillMediaItem($item, $object);
                    $resultArray[$resultArrayCount++] = $item;
                }
            }
            $response = successResponse();
            $response['count'] = $resultArrayCount;
            $response['list'] = $resultArray;
        }
    }
}
echo json_encode($response);
开发者ID:egrivel,项目名称:vacationblog,代码行数:31,代码来源:getMedia.php

示例2: testOverrideAutomaticAttributesFutureDate

 /**
  * test #14.
  * Overriding automatic attributes using a future date. Because
  * a future date is used, the record can no longer be changed after
  * it was saved.
  * @depends testSaveEmptyObject
  * @depends testSetAttributes
  * @depends testUpdate
  * @depends testOverrideAutomaticAttributesNewRecord
  */
 public function testOverrideAutomaticAttributesFutureDate()
 {
     global $testTripId1, $testMediaId1;
     // Create the object, which automatically gets the current date
     $object = new Media($testTripId1, $testMediaId1);
     $object->setType('photo');
     $object->setCaption('Caption 1');
     $object->setTimestamp('2015-09-30 12:03:45');
     $object->setLocation('location');
     $object->setWidth('900');
     $object->setHeight('600');
     $object->setDeleted('Y');
     $this->assertTrue($object->save());
     $this->assertEquals(1, $this->countTestRows());
     $originalCreated = $object->getCreated();
     $originalUpdated = $object->getUpdated();
     $originalHash = $object->getHash();
     // Change the object with different values, using a guaranteed
     // future date for the Created and Updated fields. Note that
     // the mySQL timestamp values allow for dates up to January 19,
     // 2038. Select as the future date for this test January 18, 2038
     // values after first save are unchanged
     $object->setCreated('2038-01-18 10:10:10.000000');
     $object->setUpdated('2038-01-18 10:10:11.000000');
     $object->setType('video');
     $object->setCaption('Caption 2');
     $object->setTimestamp('2015-10-01 10:01:01');
     $object->setLocation('location 2');
     $object->setWidth('640');
     $object->setHeight('480');
     $object->setDeleted('N');
     $object->setHash('future date hash');
     // Check the values before saving
     $this->assertEquals($testTripId1, $object->getTripId());
     $this->assertEquals($testMediaId1, $object->getMediaId());
     $this->assertEquals('2038-01-18 10:10:10.000000', $object->getCreated());
     $this->assertEquals('2038-01-18 10:10:11.000000', $object->getUpdated());
     $this->assertEquals('video', $object->getType());
     $this->assertEquals('Caption 2', $object->getCaption());
     $this->assertEquals('2015-10-01 10:01:01', $object->getTimestamp());
     $this->assertEquals('location 2', $object->getLocation());
     $this->assertEquals('640', $object->getWidth());
     $this->assertEquals('480', $object->getHeight());
     $this->assertEquals('N', $object->getDeleted());
     $this->assertEquals('future date hash', $object->getHash());
     // update the record, this adds a row in the database
     $this->assertTrue($object->save());
     $this->assertEquals(2, $this->countTestRows());
     // after the update, the information has been saved
     $this->assertEquals($testTripId1, $object->getTripId());
     $this->assertEquals($testMediaId1, $object->getMediaId());
     $this->assertEquals('2038-01-18 10:10:10.000000', $object->getCreated());
     $this->assertEquals('2038-01-18 10:10:11.000000', $object->getUpdated());
     $this->assertEquals('video', $object->getType());
     $this->assertEquals('Caption 2', $object->getCaption());
     $this->assertEquals('2015-10-01 10:01:01', $object->getTimestamp());
     $this->assertEquals('location 2', $object->getLocation());
     $this->assertEquals('640', $object->getWidth());
     $this->assertEquals('480', $object->getHeight());
     $this->assertEquals('N', $object->getDeleted());
     $this->assertEquals('future date hash', $object->getHash());
     // Try to update the record. This will add a row in the database
     $object->setCaption('2015-10-02');
     $object->setType('photo');
     $object->setTimestamp('Timestamp 3');
     $object->setLocation('location 3');
     $object->setWidth('1200');
     $object->setHeight('900');
     $object->setDeleted('Y');
     $this->assertTrue($object->save());
     $this->assertEquals(3, $this->countTestRows());
     // but the new information is not saved. The previously saved
     // information cannot be overwritten without manually setting the
     // updated field.
     $this->assertEquals($testTripId1, $object->getTripId());
     $this->assertEquals($testMediaId1, $object->getMediaId());
     $this->assertEquals('2038-01-18 10:10:10.000000', $object->getCreated());
     $this->assertEquals('2038-01-18 10:10:11.000000', $object->getUpdated());
     $this->assertEquals('video', $object->getType());
     $this->assertEquals('Caption 2', $object->getCaption());
     $this->assertEquals('2015-10-01 10:01:01', $object->getTimestamp());
     $this->assertEquals('location 2', $object->getLocation());
     $this->assertEquals('640', $object->getWidth());
     $this->assertEquals('480', $object->getHeight());
     $this->assertEquals('N', $object->getDeleted());
     // Note: this will FAIL in the current implementation!
     //$this->assertEquals('future date hash', $object->getHash());
 }
开发者ID:egrivel,项目名称:vacationblog,代码行数:98,代码来源:MediaTest.php

示例3: testSynchPut

 /**
  * Test #13. SYNCH request write new object.
  */
 public function testSynchPut()
 {
     global $testTripId1, $testMediaId1;
     global $synchAuthToken;
     $this->assertEquals(0, $this->countTestRows());
     $data = array('tripId' => $testTripId1, 'mediaId' => $testMediaId1, 'created' => '2015-10-01', 'updated' => '2015-10-02', 'type' => 'photo', 'caption' => 'Caption Media 1', 'timestamp' => '2015-09-30 12:03:45', 'location' => 'location', 'width' => '900', 'height' => '600', 'deleted' => 'Y', 'hash' => 'forced hash');
     $result = putApi('synchMedia.php', $data, $synchAuthToken);
     $this->assertEquals(RESPONSE_SUCCESS, $result['resultCode']);
     $this->assertEquals(1, $this->countTestRows());
     $object = new Media($testTripId1, $testMediaId1);
     $this->assertEquals('2015-10-01 00:00:00.000000', $object->getCreated());
     $this->assertEquals('2015-10-02 00:00:00.000000', $object->getUpdated());
     $this->assertEquals('photo', $object->getType());
     $this->assertEquals('Caption Media 1', $object->getCaption());
     $this->assertEquals('2015-09-30 12:03:45', $object->getTimestamp());
     $this->assertEquals('location', $object->getLocation());
     $this->assertEquals('900', $object->getWidth());
     $this->assertEquals('600', $object->getHeight());
     $this->assertEquals("Y", $object->getDeleted());
     $this->assertEquals('forced hash', $object->getHash());
 }
开发者ID:egrivel,项目名称:vacationblog,代码行数:24,代码来源:MediaApiTest.php


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