Welcome Guest, Not a member yet? Register   Sign In
Insert or Update in Save() method of Datamapper
#6

[eluser]alaminx[/eluser]
Other problem ?
country has many city
city has one country.
when I try save country to city . nothing insert to the "country_id" field
Code:
function add()
    {
        $country_id=$this->uri->segment(4);
        //if request is GET
        $country=new country($country_id);
      
        if($_SERVER['REQUEST_METHOD']=="GET")
        {
            $city=new city();  
        }
        //if request if POST
        else
        {
            $city=new city();
            $city->name=$this->input->post('name');
            //add country to city
            $city->country=$country;
        
            if($city->save())
            {
                redirect($this->admin.'countries/list_cities/'.$country_id);    
            }
        }
         $dis['base_url']=base_url();
         $dis['country']=$country;
         $dis['menu_active']="Country";
         $dis['title']="Add New City To {$country->name}";
         $dis['object']=$city;
         $dis['view']='city/add';
         $this->viewadmin($dis);
    }


The "country_id" of the city is NULL ???


Messages In This Thread
Insert or Update in Save() method of Datamapper - by El Forum - 10-14-2010, 09:04 AM
Insert or Update in Save() method of Datamapper - by El Forum - 10-14-2010, 10:29 AM
Insert or Update in Save() method of Datamapper - by El Forum - 10-14-2010, 10:42 AM
Insert or Update in Save() method of Datamapper - by El Forum - 10-14-2010, 11:20 AM
Insert or Update in Save() method of Datamapper - by El Forum - 10-14-2010, 12:06 PM
Insert or Update in Save() method of Datamapper - by El Forum - 10-14-2010, 12:11 PM
Insert or Update in Save() method of Datamapper - by El Forum - 10-14-2010, 12:28 PM
Insert or Update in Save() method of Datamapper - by El Forum - 10-14-2010, 12:36 PM
Insert or Update in Save() method of Datamapper - by El Forum - 10-14-2010, 12:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB