Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter using MySQL
#21

[eluser]toopay[/eluser]
@MaxEisley

Is everything ok, when you had FK? Then, you should FIX IT first (not deleted it!).
#22

[eluser]MaxEisley[/eluser]
InsiteFX: I get this error.

Fatal error: Call to undefined method CI_DB_mysql_driver::last_insert_id() in C:\xampplite\htdocs\www\DBS2\application\models\data_model.php on line 26
#23

[eluser]MaxEisley[/eluser]
@toopay: I will not use FK cause when i insert 1 row, all tables are bad and i cannot delete nothing, i can only delete full database.

Now i am working with FK, its small DB and i know what is FK and i dont need any mysql features for this.

I have problem written above, cannot get last_insert_id();
#24

[eluser]toopay[/eluser]
Code:
function createaddress ($town, $street, $CP, $PSC)
{
    $data = array (
       'Mesto' => $town,
       'Ulice' => $street,
       'CP'    => $CP,
       'PSC'   => $PSC
    );
    $this->db->insert('adresa', $data);  
    return $this->db->insert_id();
}
  
function createcustomer ($phone, $email, $name, $surname, $address_id)
{
    $data = array (
       'Telefon'  => $phone,
       'Email'    => $email,
       'Jmeno'    => $name,
       'Prijmeni' => $surname,
       'adresaID' => $address_id
    );
    $this->db->insert('zakaznik', $data);
}

And in controller:
Code:
$address_id = $this->data_model->createaddress($this->input->post('Town'), $this->input->post('Street'), $this->input->post('StreetN'), $this->input->post('ZIP'));

$this->data_model->createcustomer($this->input->post('Phone'), $this->input->post('Email'), $this->input->post('FirstN'), $this->input->post('SecondN'),$address_id);
#25

[eluser]MaxEisley[/eluser]
toopay: thanks, it works, i have all ok but i have used bad function mysql_insert_id() and not just insert_id()




Theme © iAndrew 2016 - Forum software by © MyBB