Пример #1
0
 /**
  * Report success.
  *
  * In this method, which pushs result object into ->results array.
  * you can use flushResult() method to clean up these 
  * result objects.
  *
  * @param string $message Success message.
  * @param array $extra Extra data.
  * @return Result
  */
 public function reportSuccess($message, $extra = array())
 {
     return $this->lastResult = Result::success($message, $extra);
 }
Пример #2
0
 /**
  * Update collection
  *
  * FIXME
  */
 public function update(array $data)
 {
     $schema = $this->getSchema();
     $dsId = $schema->getWriteSourceId();
     $conn = ConnectionManager::getInstance()->getConnection($dsId);
     $driver = $conn->createQueryDriver();
     $query = new UpdateQuery();
     $query->setWhere(clone $this->getCurrentReadQuery()->getWhere());
     $query->update($this->getTable());
     $query->set($data);
     $arguments = new ArgumentArray();
     $sql = $query->toSql($driver, $arguments);
     try {
         $this->handle = $conn->prepareAndExecute($sql, $arguments->toArray());
     } catch (Exception $e) {
         return Result::failure('Collection update failed: ' . $e->getMessage(), array('vars' => $arguments->toArray(), 'sql' => $sql, 'exception' => $e));
     }
     return Result::success('Updated', array('sql' => $sql));
 }