hello everyone, i have a serious problem when i try to update my form and i want to know if this is a bug, my form update very well in linux but when i pass my application to windows my update fails and i don’t why, it’s only the update because when i create a new record it’s works, i change my dblib connection for mssql in windows, i don’t know if this cause the problem, this is my controll
public function actionUpdate($id)
{
$model=$this->loadModel($id);
if(isset($_POST['tra_pedido2h_test']))
{
$model->attributes=$_POST['tra_pedido2h_test'];
if($model->save())
$this->redirect(array('view','id'=>$model->NUMERO));
}
$this->render('update',array(
'model'=>$model,
));
}
i set my primary key in my model, because the table doesn’t have primary key, and the weird of this, is that only i have this error when i update my record, i hope that someone can help me and sorry for my english
well, my primary key is fine, i set my primary key in my model and is the same with the controller,
public function primaryKey()
{
return 'NUMERO';
}
the weird of this is that i only have this problem in windows, because in linux works without problems, i don’t know if can be a problem with the pdo_driver for sql server in windows, because in linux i used dblib and for windows change to mssql, i was thinking the same that maybe can be a problem with the table of the db but if was a problem with the structure table would not work with linux, so really i need to solve this problem, please, someone to help me, don’t disappoint me yii developers
well, i don’t know if this problem can be in the function save, because if i execute my query without the function save, like a manual query, it works, so finally i don’t know if the problem can be in the function save or in the pdo_driver for windows because in linux my update works. This is my controller without function save and it works
$model->attributes=$_POST['tra_pedido2h'];
$connection=Yii::app()->db;
$command=$connection->createCommand("UPDATE PEDIDO2H
SET CLIENTE = $model->CLIENTE,
FECHA = '".$_POST['tra_pedido2h']['FECHA']."',
VENDEDOR = $model->VENDEDOR,
REFERENCIA4 = '$model->REFERENCIA4',
RENGLONES = $model->RENGLONES
WHERE NUMERO = $model->NUMERO");
$command->execute();
$this->redirect(array('update','id'=>$model->NUMERO));
sorry, is not work with my query, is the same error and i think that maybe is problem with my primary key because the function loadModel returns my id with a 0, like 13808.0 because in my table the ID NUMERO is defined with a presicion, but i don’t understand why in linux doesn’t return the 0
yeah thanks, well actually my problem was with the dates, in Linux my dates was fine, but in Windows returns different, maybe for the regional configuration, so i format my dates since javascript with this
$('#FECHA').change(function(event) {
var fecha = this.value;
var fecha_c = fecha.substring(6,11) + '-' + fecha.substring(0,2) + '-' + fecha.substring(3,5);
$('#model_FECHA').val(fecha_c); //y-d-m
});
so my codesource was fine, but SQL Server rejected my dates for the format that i give