| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* |
| 8 |
*/ |
| 9 |
class CJT_Models_Parameters { |
| 10 |
|
| 11 |
/** |
| 12 |
* Delete parameter or group or parameters |
| 13 |
* or all parameters associasted to specific block. |
| 14 |
* |
| 15 |
* Each Key might has only the parameterId or blockId or both of them. |
| 16 |
* |
| 17 |
* @param array array('blockId' => ID, 'parameterId' => 'ID). |
| 18 |
* @return |
| 19 |
*/ |
| 20 |
public function delete($keys) { |
| 21 |
// Initialize. |
| 22 |
$tblParams = CJTxTable::getInstance('parameter') |
| 23 |
->setTableKey(array('blockId', 'parameterId')); |
| 24 |
// Delete parameters. |
| 25 |
foreach ($keys as $key) { |
| 26 |
// Allow only blockId to be passed as scalar! |
| 27 |
if (!is_array($key)) { |
| 28 |
$key = array($key); |
| 29 |
} |
| 30 |
// Blolckid passed @index 0 while parameters id @index 1 |
| 31 |
$key = array( |
| 32 |
'blockId' => $key[0], |
| 33 |
'parameterId' => isset($key[1]) ? $key[1] : null, |
| 34 |
); |
| 35 |
// Delete record. |
| 36 |
$tblParams->setData($key) |
| 37 |
->delete(); |
| 38 |
} |
| 39 |
// Chaining. |
| 40 |
return $this; |
| 41 |
} |
| 42 |
|
| 43 |
} // End class. |
| 44 |
|