/**
  * @param SqlCrudInterface $sqlCrudInterface
  * @param array $data
  *
  * @return SqlCrudInterface
  */
 private function setData(SqlCrudInterface $sqlCrudInterface, array $data)
 {
     $columns = array_flip($sqlCrudInterface->crudColumns());
     foreach ($data as $column => $value) {
         if (isset($columns[$column])) {
             $methodName = 'set' . ucfirst($columns[$column]);
             $sqlCrudInterface->{$methodName}($value);
         }
     }
     return $sqlCrudInterface;
 }
예제 #2
0
 /**
  * @param SqlCrudInterface $sqlCrudInterface
  * @param array $conditions
  * @param null $conditionsQuery
  * @return bool|SqlCrudInterface
  * @throws MysqlException
  */
 public function update(SqlCrudInterface $sqlCrudInterface, array $conditions, $conditionsQuery = null)
 {
     // do something before we save
     $sqlCrudInterface->crudBeforeSave(false);
     $response = $this->getMysql()->update($sqlCrudInterface::crudGetSource(), $conditions, $this->getData($sqlCrudInterface), $this->getConditionsQuery($conditions, $conditionsQuery));
     if ($response !== false) {
         // do something after update
         $sqlCrudInterface->crudAfterSave(false);
         return $sqlCrudInterface;
     }
     return false;
 }