protected function updateProduct(array $data) { $dataQueryString = ''; foreach ($data as $key => $value) { $dataQueryString .= $key . '=' . '"' . $value . '",'; } $query = sprintf("UPDATE %s SET %s WHERE id = %s", ProductStruct::getTable(), rtrim($dataQueryString, ','), $data['id']); return engine::mysql($query); }
<?php /** * @var ProductStruct $product */ ?> <form method="POST" class="product new"> <? foreach(ProductStruct::getFields() as $field): ?> <? if(!$product && $field == 'id'){ continue; } $field_type = $field == 'price' ? 'number' : 'text'; ?> <div> <input type="<?php echo $field_type; ?> " class="input tooltipstered" name="<?php echo $field; ?> " placeholder="<?php echo $field; ?>