How to update the database to several codeigniter-related tables

Asked

Viewed 164 times

3

I’m trying to do an update with codeigniter on two related tables, but I’m not getting it.

I’m using the following code.

    $this->db->set('p.page', $dados['page']);
    $this->db->set('c.title_map', $dados['title_map']);
    $this->db->where('p.id', $idpage);
    $this->db->where('c.pages_id', $idpage);
    $this->db->limit(1);
    $this->db->update('pages as p, customers as c', $dados, $condicao);

And I’m getting the following mistake.

    Ocorreu um erro de banco de dados

    Error Number: 1146
    Table 'newaircobraz.pages as p, customers' doesn't exist

    UPDATE `pages as p, customers` as `c` SET `p`.`page` = 'OK Customers', `c`.`title_map` = 'OK Click the red dots to view customers in each country.', `id` = 'EN', `page` = 'OK Customers', `title_map` = 'OK Click the red dots to view customers in each country.' WHERE `p`.`id` = '3' AND `c`.`pages_id` = '3' AND `id` = 'EN' LIMIT 1

    Filename: C:/xampp/htdocs/aircobraz/application/models/paginas_model.php
    Line Number: 75
  • According to the error message, this table 'page as p, customers as c' does not exist. Verify the existence of the query to ensure that the query works correctly.

1 answer

2

Update one at a time.

$this->db->update('pages',$dados,$condicao);

$this->db->update('customers',$dados,$condicao);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.