$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; } public static function Delete(&$item, $family, $key) { if (is_array($item)) { 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]); } } // re-order the array index $item['iconfig'] = array_values($item['iconfig']); } 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) ); } }