/** * Removes a non-generic fieldset from a given document type. * * (Generic fieldsets are made available to and are required for all * (subsequent) documents. Non-generic fieldsets are made available * to and are required for all (subsequent) documents that have a * particular document type.) */ function removeSetsFromDocumentType($oDocumentType, $aFieldsets) { if (is_object($oDocumentType)) { $iDocumentTypeId = $oDocumentType->getId(); } else { $iDocumentTypeId = $oDocumentType; } if (!is_array($aFieldsets)) { $aFieldsets = array($aFieldsets); } if (empty($aFieldsets)) { return true; } $aIds = array(); foreach ($aFieldsets as $oFieldset) { if (is_object($oFieldset)) { $iFieldsetId = $oFieldset->getId(); } else { $iFieldsetId = $oFieldset; } $aIds[] = $iFieldsetId; } // Converts to (?, ?, ?) for query $sParam = DBUtil::paramArray($aIds); $aWhere = KTUtil::whereToString(array(array('document_type_id = ?', array($iDocumentTypeId)), array("fieldset_id IN ({$sParam})", $aIds))); $sTable = KTUtil::getTableName('document_type_fieldsets'); $aQuery = array("DELETE FROM {$sTable} WHERE {$aWhere[0]}", $aWhere[1]); return DBUtil::runQuery($aQuery); }
<?php require_once "../../../config/dmsDefaults.php"; require_once KT_LIB_DIR . "/util/ktutil.inc"; $aSource = array(array("active = ?", array(true)), array("foo = ? AND asdf = ?", array(5, "ff"))); $aResults = KTUtil::whereToString($aSource); $aExpectedResults = array("active = ? AND foo = ? AND asdf = ?", array(true, 5, "ff")); if ($aResults === $aExpectedResults) { print "Success!\n"; } else { print "Failure!\n"; print "Received: " . print_r($aResults, true) . "\n"; print "Expected: " . print_r($aExpectedResults, true) . "\n"; }
function listGroups($aGivenOptions = null) { if (is_null($aGivenOptions)) { $aGivenOptions = array(); } $aDefaultOptions = array(); $aOptions = kt_array_merge($aDefaultOptions, $aGivenOptions); $aWhere = array(); /* if ($aOptions["active"] === true) { $aWhere[] = array("active = ?", true); } */ $sWhere = KTUtil::whereToString($aWhere); return Group::getList($sWhere); }