Replies: 2 comments 6 replies
-
Did you try to debug all post data? I see in post you get $this->request->getPost('serviceordertype')... For id field. Are you sure its correct? Just for test- try simple update with one field and just change that field to existing type id. |
Beta Was this translation helpful? Give feedback.
6 replies
-
it will point to the new IP on the authoritative server, and recursive systems will update after their Cache based on the record TTL has expired.... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi.
Lemme try to explain what´s happening.
I have a table with the fields below:
``service_orders
(
id` int unsigned NOT NULL AUTO_INCREMENT,`service_order_number` int unsigned NOT NULL DEFAULT '0',
`service_order_type_id` int unsigned NOT NULL DEFAULT '0',
`equipment_id` int unsigned NOT NULL DEFAULT '0',
`address` varchar(328) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0',
`contact` varchar(60) COLLATE utf8mb4_general_ci DEFAULT NULL,
`distance` int unsigned DEFAULT NULL,
`time` int unsigned DEFAULT NULL,
`occurence` mediumtext COLLATE utf8mb4_general_ci,
`technical_report` mediumtext COLLATE utf8mb4_general_ci,
`client_observation` mediumtext COLLATE utf8mb4_general_ci,
`technician` varchar(60) COLLATE utf8mb4_general_ci DEFAULT NULL,
`client_name` varchar(60) COLLATE utf8mb4_general_ci DEFAULT NULL,
`hours_date` date DEFAULT NULL,
`hours` int unsigned DEFAULT NULL,
`kilometers_date` date DEFAULT NULL,
`kilometers` int unsigned DEFAULT NULL,
`closure_date` timestamp NULL DEFAULT NULL,
`status` enum('A','F','C','E') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'A',
`user_id` int unsigned DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `FK_service_orders_service_order_types` (`service_order_type_id`),
KEY `FK_service_orders_equipments` (`equipment_id`),
KEY `FK_service_orders_users` (`user_id`),
CONSTRAINT `FK_service_orders_equipments` FOREIGN KEY (`equipment_id`) REFERENCES `equipments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_service_orders_service_order_types` FOREIGN KEY (`service_order_type_id`) REFERENCES `service_order_types` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_service_orders_users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2039 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;`
Here I have the model
`<?php
declare(strict_types=1);
namespace Smartman\Models;
use Phalcon\Mvc\Model;
//use Phalcon\Filter\Validation;
//use Phalcon\Filter\Validation\Validator\Uniqueness;
/**
Smartman\Models\ServiceOrders
ServiceOrders per account
*/
class ServiceOrders extends Model
{
/**
*/
public $id;
/**
*/
public $service_order_number;
/**
*/
public $service_order_type_id;
/**
*/
public $equipment_id;
/**
*/
public $address;
/**
*/
public $contact;
/**
*/
public $distance;
/**
*/
public $time;
/**
*/
public $occurence;
/**
*/
public $technical_report;
/**
*/
public $client_observation;
/**
*/
public $technician;
/**
*/
public $client_name;
/**
*/
public $hours_date;
/**
*/
public $hours;
/**
*/
public $kilometers_date;
/**
*/
public $kilometers;
/**
*/
public $closure_date;
/**
*/
public $status;
/**
*/
public $user_id;
/**
*/
public $created_at;
/**
*/
public $updated_at;
public function initialize()
{
$this->belongsTo(
'service_order_type_id',
'Smartman\Models\ServiceOrderTypes',
'id',
array('alias' => 'serviceordertype')
);
}
}`
I have two methods in the controller, create and edit.
Whaen I create a new record (service order) it goes well, but when I edit this record, it updates all the fields except the service_order_type_id.
Here´s the edit method:
`public function editAction($id)
{
$serviceorder = ServiceOrders::findFirstById($id);
I run using Xdebug and it receives the correct value from $_POST, it assigns too, but after it saves the field service_order_type_id reverts to the original value.
If I only change the field service_order_type_id the record doesn´t update. The field updated_at doesn´t change the value and it givves me no errors.
I know that the model is right because in the create method it´s working fine. In the debug it receives and assign a new value, but don´t know what´s happening when I try to save. The other fields updates without any errors.
Beta Was this translation helpful? Give feedback.
All reactions