|
Site Admin |
|
Joined: Mon Jun 07, 2004 11:48 am Posts: 1964 Location: Brisbane, Australia
|
[quote="el_geto"]and please correct me if I'm wrong No, you're spot on.
Interesting. The function that does this (m_oa_group->update_specific_group) hasn't changed between 9.2 and my current code. The function is below. I say interesting because your original SQL error as quoted would be produced by the second last SQL creation line - [code]$sql_insert = substr_replace($sql_select, "INSERT INTO oa_group_sys (system_id, group_id, group_sys_type) ", 0, 0);[/code] This should not be executed against the DB as the very next line further alters this SQL.
I cannot replicate the issue. If you export a Group you know is showing this error, post it here with exact step by step instructions on how you can reporduce it, we may be able to get some further info...
I have inserted a couple of echo's into my code and altered a Group. The function works and shows the following for the first and second SQL generations statements.
[code]$sql_insert = substr_replace($sql_select, "INSERT INTO oa_group_sys (system_id, group_id, group_sys_type) ", 0, 0); produces INSERT INTO oa_group_sys (system_id, group_id, group_sys_type) SELECT distinct(system.system_id) FROM system WHERE system.man_org_id = '1' AND system.man_status = 'production' [/code] aThis output would seem to match the SQL you posted, but as stated it should not be run against the DB as the very next statement alters the SQL further, like so - [code]$sql_insert = str_ireplace("SELECT DISTINCT(system.system_id)", "SELECT DISTINCT(system.system_id), '" . $group_id . "', 'system'", $sql_insert); produces INSERT INTO oa_group_sys (system_id, group_id, group_sys_type) SELECT DISTINCT(system.system_id), '33', 'system' FROM system WHERE system.man_org_id = '1' AND system.man_status = 'production' [/code]
[code] function update_specific_group($group_id) { # get the group select $sql = "SELECT group_dynamic_select FROM oa_group WHERE group_id = ? LIMIT 1"; $data = array($group_id); $query = $this->db->query($sql, $data); foreach ($query->result() as $myrow) { $sql_select = $myrow->group_dynamic_select; } # remove the existing systems in this group $sql_delete = "DELETE FROM oa_group_sys WHERE group_id = ?"; $data = array($group_id); $delete = $this->db->query($sql_delete, $data) or die ("Error with delete from oa_group_sys"); # update the group with all systems that match $sql_insert = substr_replace($sql_select, "INSERT INTO oa_group_sys (system_id, group_id, group_sys_type) ", 0, 0); $sql_insert = str_ireplace("SELECT DISTINCT(system.system_id)", "SELECT DISTINCT(system.system_id), '" . $group_id . "', 'system'", $sql_insert); $insert = $this->db->query($sql_insert); }[/code]
_________________ Support and Development hours available from [url=https://opmantek.com]Opmantek[/url]. Please consider a purchase to help make Open-AudIT better for everyone.
|
|