src/libraries/adapters/DatabaseMySql.php
/**
    * Formats a photo to be updated or added to the database.
    * Primarily to properly format tags as an array.
    *
    * @param string $id ID of the photo.
    * @param array $params Parameters for the photo to be normalized.
    * @return array
    */
Formats a photo to be updated or added to the database.
Primarily to properly format tags as an array.

@param string $id ID of the photo.
@param array $params Parameters for the photo to be normalized.
@return array
Formats a photo to be updated or added to the database . Primarily to properly format tags as an array . @param string $id ID of the photo . @param array $params Parameters for the photo to be normalized . @return array
private function preparePhoto($id, $params)
  {
    $paramsOut = $bindings = $exif = $extra = array();
    foreach($params as $key => $value)
    {
      switch($key)
      {
        case 'exif':
        case 'exifOrientation':
        case 'exifCameraMake':
        case 'exifCameraModel':
        case 'exifExposureTime':
        case 'exifFNumber':
        case 'exifMaxApertureValue':
        case 'exifMeteringMode':
        case 'exifFlash':
        case 'exifFocalLength':
        case 'exifISOSpeed':
        case 'gpsAltitude':
          $exif[$key] = $value;
          break;
        case 'extra':
        case 'extraDropboxSource':
          $extra[$key] = $value;
          break;
        default:
          if(($key == 'latitude' || $key == 'longitude') && empty($value))
            $value = null;
          $bindings[":{$key}"] = $value;
          $paramsOut[$key] = ":{$key}";
          break;
      }
    }
    if(!empty($exif))
    {
      $bindings[':exif'] = json_encode($exif);
      $paramsOut['exif'] = ':exif';
    }
    if(!empty($extra))
    {
      $bindings[':extra'] = json_encode($extra);
      $paramsOut['extra'] = ':extra';
    }
    if(isset($params['dateTaken']))
    {
      $invHours = str_pad(intval(23-date('H', $params['dateTaken'])), 2, '0', STR_PAD_LEFT);
      $invMins = str_pad(intval(59-date('i', $params['dateTaken'])), 2, '0', STR_PAD_LEFT);
      $invSecs = str_pad(intval(59-date('s', $params['dateTaken'])), 2, '0', STR_PAD_LEFT);
      $bindings[':dateSortByDay'] = sprintf('%s%s%s%s', date('Ymd', $params['dateTaken']), $invHours, $invMins, $invSecs);
      $paramsOut['dateSortByDay'] = ':dateSortByDay';
    }
    $paramsOut['::bindings'] = $bindings;
    return $paramsOut;
  }
private function preparePhoto ( $ id , $ params ) { $ paramsOut = $ bindings = $ exif = $ extra = array ( ) ; foreach ( $ params as $ key => $ value ) { switch ( $ key ) { case 'exif' : case 'exifOrientation' : case 'exifCameraMake' : case 'exifCameraModel' : case 'exifExposureTime' : case 'exifFNumber' : case 'exifMaxApertureValue' : case 'exifMeteringMode' : case 'exifFlash' : case 'exifFocalLength' : case 'exifISOSpeed' : case 'gpsAltitude' : $ exif [ $ key ] = $ value ; break ; case 'extra' : case 'extraDropboxSource' : $ extra [ $ key ] = $ value ; break ; default : if ( ( $ key == 'latitude' || $ key == 'longitude' ) && empty ( $ value ) ) $ value = null ; $ bindings [ " : { $ key } " ] = $ value ; $ paramsOut [ $ key ] = " : { $ key } " ; break ; } } if ( ! empty ( $ exif ) ) { $ bindings [ ':exif' ] = json_encode ( $ exif ) ; $ paramsOut [ 'exif' ] = ':exif' ; } if ( ! empty ( $ extra ) ) { $ bindings [ ':extra' ] = json_encode ( $ extra ) ; $ paramsOut [ 'extra' ] = ':extra' ; } if ( isset ( $ params [ 'dateTaken' ] ) ) { $ invHours = str_pad ( intval ( 23 - date ( 'H' , $ params [ 'dateTaken' ] ) ) , 2 , '0' , STR_PAD_LEFT ) ; $ invMins = str_pad ( intval ( 59 - date ( 'i' , $ params [ 'dateTaken' ] ) ) , 2 , '0' , STR_PAD_LEFT ) ; $ invSecs = str_pad ( intval ( 59 - date ( 's' , $ params [ 'dateTaken' ] ) ) , 2 , '0' , STR_PAD_LEFT ) ; $ bindings [ ':dateSortByDay' ] = sprintf ( '%s%s%s%s' , date ( 'Ymd' , $ params [ 'dateTaken' ] ) , $ invHours , $ invMins , $ invSecs ) ; $ paramsOut [ 'dateSortByDay' ] = ':dateSortByDay' ; } $ paramsOut [ '::bindings' ] = $ bindings ; return $ paramsOut ; }
Formats a photo to be updated or added to the database.
Formats a photo to be updated or added to the database .
// when lat/long is empty set value to null else it is stored as 0. Gh-313 // here we seed a field for the default sort order of day descending and time ascending