Fixes in fields for new mysql behaviour

This commit is contained in:
Antonio de la Rosa 2019-06-18 23:32:58 +02:00
parent 94e3d63b0b
commit 29faed4b35
7 changed files with 27 additions and 6 deletions

View file

@ -23,6 +23,7 @@ class DoubleField extends PhangoField {
$this->size=$size;
$this->form='PhangoApp\PhaModels\Forms\BaseForm';
$this->value=0;
}

View file

@ -42,6 +42,7 @@ class ForeignKeyField extends IntegerField{
$this->protected=0;
//($name, $value, $model, $field_name, $field_value)
$this->parameters=array($this->related_model, $name_field, $this->related_model->idmodel);
$this->default_value='NULL';
}

View file

@ -29,6 +29,7 @@ class IntegerField extends PhangoField {
$this->max_num=$max_num;
$this->quot_open='';
$this->quot_close='';
$this->default_value=0;
}

View file

@ -14,6 +14,7 @@ class MoneyField extends DoubleField{
parent::__construct(11, true, 0, 0);
$this->form='PhangoApp\PhaModels\Forms\MoneyForm';
$this->default_value=0;
}

View file

@ -26,6 +26,7 @@ class SerializeField extends PhangoField {
{
$this->related_type=$related_type;
$this->default_value='{}';
}

View file

@ -23,6 +23,7 @@ class TextField extends PhangoField {
$this->form='PhangoApp\PhaModels\Forms\TextAreaForm';
$this->multilang=$multilang;
$this->default_value='';
}
@ -74,4 +75,4 @@ class TextField extends PhangoField {
}
}
?>
?>

View file

@ -680,8 +680,12 @@ class Webmodel {
{
//Foreach for create the query that comes from the $post array
foreach($fields as $key => $field)
$components=$this->components;
unset($components[$this->idmodel]);
foreach($components as $key => $field)
{
$quot_open=$this->components[$key]->quot_open;
@ -699,12 +703,23 @@ class Webmodel {
$fields[$key]='NULL';
}
}
$arr_fields[]=$quot_open.$fields[$key].$quot_close;
if(!isset($fields[$key]))
{
$arr_fields[]=$quot_open.$this->components[$key]->default_value.$quot_close;
}
else
{
$arr_fields[]=$quot_open.$fields[$key].$quot_close;
}
}
return 'insert into '.$this->name.' (`'.implode("`, `", array_keys($fields)).'`) VALUES ('.implode(", ",$arr_fields).') ';
return 'insert into '.$this->name.' (`'.implode("`, `", array_keys($components)).'`) VALUES ('.implode(", ",$arr_fields).') ';
}