src/libraries/adapters/DatabaseMySql.php
/**
    * Add a new photo to the database
    * This method does not overwrite existing values present in $params - hence "new photo".
    *
    * @param string $id ID of the photo to update which is always 1.
    * @param array $params Attributes to update.
    * @return boolean
    */
Add a new photo to the database
This method does not overwrite existing values present in $params - hence "new photo".

@param string $id ID of the photo to update which is always 1.
@param array $params Attributes to update.
@return boolean
Add a new photo to the database This method does not overwrite existing values present in $params - hence " new photo " . @param string $id ID of the photo to update which is always 1 . @param array $params Attributes to update . @return boolean
public function putPhoto($id, $params)
  {
    $params['id'] = $id;
    $params['owner'] = $this->owner;
    $tags = null;
    if(isset($params['tags']) && !empty($params['tags']))
      $tags = (array)explode(',', $params['tags']);
    if(isset($params['groups']))
    {
      $this->updateGroupToPhotoMapping($id, $params['groups']);
      $params['groups'] = preg_replace(array('/^,|,$/','/,{2,}/'), array('', ','), $params['groups']);
    }
    if(isset($params['albums']))
    {
      $this->updateAlbumToPhotoMapping($id, $params['albums']);
      $params['albums'] = preg_replace(array('/^,|,$/','/,{2,}/'), array('', ','), $params['albums']);
    }
    $params = $this->preparePhoto($id, $params);
    $bindings = $params['::bindings'];
    $stmt = $this->sqlInsertExplode($params, $bindings);
    $result = $this->db->execute("INSERT INTO `{$this->mySqlTablePrefix}photo` ({$stmt['cols']}) VALUES ({$stmt['vals']})", $bindings);
    if(!empty($tags))
    {
      foreach($tags as $tag)
        $this->addTagToElement($id, $tag, 'photo');
    }
    return ($result !== false);
  }
public function putPhoto ( $ id , $ params ) { $ params [ 'id' ] = $ id ; $ params [ 'owner' ] = $ this -> owner ; $ tags = null ; if ( isset ( $ params [ 'tags' ] ) && ! empty ( $ params [ 'tags' ] ) ) $ tags = ( array ) explode ( ',' , $ params [ 'tags' ] ) ; if ( isset ( $ params [ 'groups' ] ) ) { $ this -> updateGroupToPhotoMapping ( $ id , $ params [ 'groups' ] ) ; $ params [ 'groups' ] = preg_replace ( array ( '/^,|,$/' , '/,{2,}/' ) , array ( '' , ',' ) , $ params [ 'groups' ] ) ; } if ( isset ( $ params [ 'albums' ] ) ) { $ this -> updateAlbumToPhotoMapping ( $ id , $ params [ 'albums' ] ) ; $ params [ 'albums' ] = preg_replace ( array ( '/^,|,$/' , '/,{2,}/' ) , array ( '' , ',' ) , $ params [ 'albums' ] ) ; } $ params = $ this -> preparePhoto ( $ id , $ params ) ; $ bindings = $ params [ '::bindings' ] ; $ stmt = $ this -> sqlInsertExplode ( $ params , $ bindings ) ; $ result = $ this -> db -> execute ( " INSERT INTO ` { $ this -> mySqlTablePrefix } photo` ( { $ stmt [ 'cols' ] } ) VALUES ( { $ stmt [ 'vals' ] } ) " , $ bindings ) ; if ( ! empty ( $ tags ) ) { foreach ( $ tags as $ tag ) $ this -> addTagToElement ( $ id , $ tag , 'photo' ) ; } return ( $ result !== false ) ; }
Add a new photo to the database
 This method does not overwrite existing values present in $params - hence "new photo".
Add a new photo to the database This method does not overwrite existing values present in $params - hence " new photo " .
// TODO: Generalize this and use for tags too -- @jmathai // TODO: Generalize this and use for tags too -- @jmathai