public function addManufacturer($data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer SET name = '" . $this->db->escape($data['name']) . "', sort_order = '" . (int)$data['sort_order'] . "'");
$manufacturer_id = $this->db->getLastId();
if (isset($data['image'])) {
$this->db->query("UPDATE " . DB_PREFIX . "manufacturer SET image = '" . $this->db->escape($data['image']) . "' WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
}
if ($data['map']) {
$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer_contact SET contact = '" . $this->db->escape($data['contact']) . "', phone = '" . $this->db->escape($data['phone']) . "', email = '" . $this->db->escape($data['email']) . "', address = '" . $this->db->escape($data['address']) . "', country = '" . $this->db->escape($data['country']) . "', code = '" . $this->db->escape($data['code']) . "', account = '" . $this->db->escape($data['account']) . "', rep_phone = '" . $this->db->escape($data['rep_phone']) . "', rep_cell = '" . $this->db->escape($data['rep_cell']) . "', account = '" . $this->db->escape($data['account']) . "', fax = '" . $this->db->escape($data['fax']) . "', csr_name = '" . $this->db->escape($data['csr_name']) . "', csr_phone = '" . $this->db->escape($data['csr_phone']) . "', csr_email = '" . $this->db->escape($data['csr_email']) . "', csr_fax = '" . $this->db->escape($data['csr_fax']) . "', map = '" . (int)$data['map'] . "' WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
}
Page 1 of 1
Setting new table in Opencart
#1
Posted 09 January 2012 - 05:07 PM
I'm having an issue getting the manufacturer_id to set in each table when I insert a new one. For some reason it only sets in the original table and I cant figure out why.
#2
Posted 09 January 2012 - 05:25 PM
I'm not amazing at OpenCart but taking a look at your code that addManufacturer function is only creating one new row in your table from DB_PREFIX. Maybe your questions is worded incorrectly? There's nowhere else where the ID is being inserted or 'set'.
#3
Posted 09 January 2012 - 05:38 PM
I've been looking for somewhere to set the id, but as far as I can see it's created upon making a new table... however I cant figure out where to add a new table to create the same id. I've created 3 new tables but they are not being populated once I add a manufactiurer
#4
Posted 10 January 2012 - 09:38 AM
Gaelen, on 09 January 2012 - 05:38 PM, said:
I've been looking for somewhere to set the id, but as far as I can see it's created upon making a new table... however I cant figure out where to add a new table to create the same id. I've created 3 new tables but they are not being populated once I add a manufactiurer
You are still not making sense with this.
The manufacturerID is created when you create a new 'row' in the table.
$manufacturer_id = $this->db->getLastId();
The above gives you the id of the row that was just inserted.
The easiest thing to do is start from the beginning.
What is the structure of all the tables that you are dealing with?
#5
Posted 10 January 2012 - 05:26 PM
I realized that about 30min after I posted this, got it all working great now! thanks
- ← Stop Error Log On Apache
- Server Side (PHP, Databases, ASP.NET, etc)
- Loking for suggestions/advice on new website →
Share this topic:
Page 1 of 1
Help
















