Problem z aktualizacją

Witam

Mam ci Takie coś:


 

public function __construct($id)

    {

        $this->IdKlienta=$id;

        $this->Status=Clients::model()->findByPk($id);

    }


public function ZmianaStatusu()

    {

        echo '<br>Obecny Status:'.var_dump($this->Status).'<br>';

        $this->Status->status_id_status=$_POST['Clients'];

        Echo '<br>Status:'.var_dump($this->Status).'<br>';

        $this->Status->save();

    }

ładnie mi zmienia "status_id_status" na to co dostaje w POST, ale nie mam pomysłu czemu nie zapisuje zmian do Bazy pod wywołaniu Save. Macie pomysł jak to sprawdzić i gdzie:D?

Wywołaj wynik metody $this->Status->getErrors(), prawdopodobnie to problem z walidacją.

Pomogło:D tylko teraz przypomnieć sobie podstawy :D jak zamienić string na integer ;D ( zawsze PHP to za Mnie robił;D )


object(Clients)#74 (11) { ["_new":"CActiveRecord":private]=> bool(false) ["_attributes":"CActiveRecord":private]=> array(16) { ["id_clients"]=> string(2) "17" ["cName"]=> string(3) "ggg" ["cFirstName"]=> string(2) "pl" ["cPhone"]=> string(6) "456687" ["cEmail"]=> NULL ["cNIP"]=> string(10) "8551073826" ["user_id_user"]=> NULL ["status_id_status"]=> string(1) "1" ["accrued_commission"]=> NULL ["create_date"]=> string(19) "2014-10-05 20:10:00" ["update_date"]=> NULL ["commission_date"]=> NULL ["type_of_offer_id_offer"]=> NULL ["agents_id_agent"]=> NULL ["commision"]=> NULL ["typ_oferty_idtyp_oferty"]=> string(1) "0" } ["_related":"CActiveRecord":private]=> array(0) { } ["_c":"CActiveRecord":private]=> NULL ["_pk":"CActiveRecord":private]=> string(2) "17" ["_alias":"CActiveRecord":private]=> string(1) "t" ["_errors":"CModel":private]=> array(0) { } ["_validators":"CModel":private]=> NULL ["_scenario":"CModel":private]=> string(6) "update" ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } 

Obecny Status:

object(Clients)#74 (11) { ["_new":"CActiveRecord":private]=> bool(false) ["_attributes":"CActiveRecord":private]=> array(16) { ["id_clients"]=> string(2) "17" ["cName"]=> string(3) "ggg" ["cFirstName"]=> string(2) "pl" ["cPhone"]=> string(6) "456687" ["cEmail"]=> NULL ["cNIP"]=> string(10) "8551073826" ["user_id_user"]=> NULL ["status_id_status"]=> array(1) { ["status_id_status"]=> string(1) "2" } ["accrued_commission"]=> NULL ["create_date"]=> string(19) "2014-10-05 20:10:00" ["update_date"]=> NULL ["commission_date"]=> NULL ["type_of_offer_id_offer"]=> NULL ["agents_id_agent"]=> NULL ["commision"]=> NULL ["typ_oferty_idtyp_oferty"]=> string(1) "0" } ["_related":"CActiveRecord":private]=> array(0) { } ["_c":"CActiveRecord":private]=> NULL ["_pk":"CActiveRecord":private]=> string(2) "17" ["_alias":"CActiveRecord":private]=> string(1) "t" ["_errors":"CModel":private]=> array(0) { } ["_validators":"CModel":private]=> NULL ["_scenario":"CModel":private]=> string(6) "update" ["_e":"CComponent":private]=> NULL ["_m":"CComponent":private]=> NULL } 

Status:

array(1) { ["status_id_status"]=> array(1) { [0]=> string(42) "Zawartość pola Status musi być liczbą." } }

Zmiana zadziałała:D


$this->Status->status_id_status=  intval($_POST['Clients']['status_id_status']);

lub można zapisać bez walidacji:


$this->Status->save(false);



Sprawdź czy zadziałała dobrze - pod status_id_status podstawiałeś tablice, dlatego pojawiał się błąd. Prawidłowo powinno być:


        $this->Status=$_POST['Clients'];

albo


        $this->Status->status_id_status=$_POST['Clients']['status_id_status'];