I'd like perform query like that one in symfony while using Propel ORM:

UPDATE ADS SET HITS=HITS+1 WHERE ID=10;

I understand that Propel API allow me set a formerly fixed value for any column of the given record, however i certainly don't wish to retrieve the column value first before giving an update query since you will find concurrent access.

Please, how could I accomplish this?

Thanks.

This works in Symfony 1.3/1.4:

in AdsPeer:

public static function incrementHits($id)
{
  $con = Propel::getConnection(AdsPeer::DATABASE_NAME);
  $query = 'UPDATE hits SET hits + 1 WHERE id = '.$id;
  sfContext::getInstance()->getLogger()->crit($query);
  $stmt = $con->prepare($query);
  $rs = $stmt->execute();
}

To make use of:

AdsPeer::incrementHits($id);

HTH

Mike

If you want you are able to perform a Select using SQL in propel.

Here's a good example:

class BookPeer extends BaseBookPeer {
  .
  .
  .
  /**
   * Get just the Books that have not been reviewed.
   * @return array Book[]
   */
  function getUnreviewedBooks() {
    $con = Propel::getConnection(DATABASE_NAME);

    // if not using a driver that supports sub-selects
    // you must do a cross join (left join w/ NULL)
    $sql = "SELECT books.* FROM books WHERE ".
           "NOT EXISTS (SELECT id FROM review WHERE book_id = book.id)";

    $stmt = $con->createStatement();
    $rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_NUM);

    return parent::populateObjects($rs);    
  }

You can test this with update too.