$family, 'k' => $key, 'v' => $value, 'sharing' => $sharing); if(is_null($idx)) $item['iconfig'][] = $entry; else $item['iconfig'][$idx] = $entry; return $value; } if(intval($item)) $iid = intval($item); if(! $iid) return false; if(self::Get($item, $family, $key) === false) { $r = q("insert into iconfig( iid, cat, k, v, sharing ) values ( %d, '%s', '%s', '%s', %d ) ", intval($iid), dbesc($family), dbesc($key), dbesc($dbvalue), intval($sharing) ); } else { $r = q("update iconfig set v = '%s', sharing = %d where iid = %d and cat = '%s' and k = '%s' ", dbesc($dbvalue), intval($sharing), intval($iid), dbesc($family), dbesc($key) ); } if(! $r) return false; return $value; } static public function Delete(&$item, $family, $key) { $is_item = false; $idx = null; if(is_array($item)) { $is_item = true; if(is_array($item['iconfig'])) { for($x = 0; $x < count($item['iconfig']); $x ++) { if($item['iconfig'][$x]['cat'] == $family && $item['iconfig'][$x]['k'] == $key) { unset($item['iconfig'][$x]); } } } return true; } if(intval($item)) $iid = intval($item); if(! $iid) return false; return q("delete from iconfig where iid = %d and cat = '%s' and k = '%s' ", intval($iid), dbesc($family), dbesc($key) ); } }