예제 #1
0
 /**
  * Update column in rows by array of primary key values.
  * 
  * @param string $column
  * @param array|string $ids
  * @param array $value
  * @return bool|array
  */
 public function bulkUpdate($ids, array $data)
 {
     if (!is_array($ids)) {
         $ids = trim($ids);
         if ($ids == "") {
             return false;
         }
         $ids = [$ids];
     }
     if (count($ids) == 0) {
         return false;
     }
     $updateData = [];
     foreach ($data as $key => $value) {
         $column = isset($this->_columns[$key]) ? $this->_columns[$key] : $this->getColumnByName($key);
         if ($column === false) {
             return false;
         }
         $name = $column->getName();
         if (null !== $this->_form) {
             if (!($field = $this->_form->getFieldByKey($key))) {
                 $field = $this->_form->getFieldByName($name);
             }
             $field->setValue($value);
             $saveData = $field->getSaveData();
             $updateData[$saveData['key']] = $saveData['value'];
         } else {
             $updateData[$name] = $value;
         }
     }
     return $this->_container->update($ids, $updateData);
 }
예제 #2
0
 /**
  * Update container data source
  * 
  * @param \Engine\Crud\Container\Grid\Adapter $dataSource
  * @return \Engine\Crud\Grid\Column\JoinOne
  */
 public function updateDataSource($dataSource)
 {
     $columns = [$this->_key => $this->_column];
     if (!empty($this->_columns)) {
         $columns = is_array($this->_columns) ? array_merge($columns, $this->_columns) : array_merge($columns, [$this->_columns => $this->_columns]);
     }
     $dataSource->columnsJoinOne($this->_path, $columns);
     return $this;
 }
예제 #3
0
 /**
  * Update grid container
  *
  * @param \Engine\Crud\Container\Grid\Adapter $container
  * @return \Engine\Crud\Grid\Column
  */
 public function updateContainer(\Engine\Crud\Container\Grid\Adapter $container)
 {
     $container->setColumn($this->_key, $this->_name, $this->_useTableAlias, $this->_useCorrelationTableName);
     return $this;
 }
예제 #4
0
 /**
  * Update container data source
  * 
  * @param \Engine\Crud\Container\Grid\Adapter $dataSource
  * @return \Engine\Crud\Grid\Column\JoinMany
  */
 public function updateDataSource($dataSource)
 {
     if (!$this->_separateQueries) {
         $dataSource->columnsJoinMany($this->_path, $this->_key, $this->_column, $this->_orderBy, $this->_separator);
     }
     return $this;
 }