private function GetCount($value) { $connection = $this->prepared->Connection(); $sql = new Sql\Builder($connection); $params = array_fill(0, $this->numPlaceholders, $sql->Value($value)); $reader = $connection->ExecutePrepared((string) $this->prepared, $params); $result = 0; if ($reader->Read()) { $result = (int) $reader->ByIndex(0); } $reader->Close(); return $result; }
/** * Gets constraint rules for a foreign key constraint * @param string $constraintName The constraint name as input parameter * @param ConstraintRule $onUpdate The update rule as output parameter * @param ConstraintRule $onDelete The delete rule as output parameter */ private function GetConstraintRules($constraintName, ConstraintRule &$onUpdate = null, ConstraintRule &$onDelete = null) { $sql = new Sql\Builder($this); $tbl = $sql->Table('information_schema.REFERENTIAL_CONSTRAINTS', array('CONSTRAINT_NAME', 'UPDATE_RULE', 'DELETE_RULE')); $where = $sql->Equals($tbl->Field('CONSTRAINT_NAME'), $sql->Value($constraintName)); $selectList = $sql->SelectList($tbl->Field('UPDATE_RULE')); $selectList->Add($tbl->Field('DELETE_RULE')); $select = $sql->Select(false, $selectList, $tbl, $where); $reader = $this->ExecuteQuery((string) $select); if ($reader->Read()) { $onUpdate = ConstraintRule::ByValue($reader->ByName('UPDATE_RULE')); $onDelete = ConstraintRule::ByValue($reader->ByName('DELETE_RULE')); } }
/** * Clears installed bundles */ private function ClearInstalledBundles() { //Clear bundles without code folder $bundles = PathUtil::Bundles(); $sql = new Sql\Builder($this->connection); $inList = $sql->InListFromValues($bundles); $tbl = InstalledBundle::Schema()->Table(); $where = $sql->NotIn($tbl->Field('Bundle'), $inList); InstalledBundle::Schema()->Delete($where); //Clear failed bundles $failedList = $sql->InListFromValues(array_keys($this->failedBundles)); if ($failedList) { InstalledBundle::Schema()->Delete($sql->In($tbl->Field('Bundle'), $failedList)); } }