function SetupExecute() { $out = ''; $connection = Database::Connect(); if (isset($_POST['install_base64']) && isset($_POST['install_base64']) == true) { $initialData = file_get_contents('../plugins/base64_install.sql'); $statements = explode('|', $initialData); if (sizeof($statements) > 0) { foreach ($statements as $statement) { if (trim($statement) != '') { Database::NonQuery($statement, $connection); } } } $out .= "<textarea>INSTALL SUCCESSFUL\n\n"; $out .= "Make sure you set \$configuration[db_encoding] = 1 in the configuration file.</textarea>"; } else { if (isset($_POST['uninstall_base64']) && $_POST['uninstall_base64'] == true) { $initialData = file_get_contents('../plugins/base64_uninstall.sql'); $statements = explode('|', $initialData); if (sizeof($statements) > 0) { foreach ($statements as $statement) { if (trim($statement) != '') { Database::NonQuery($statement, $connection); } } } $out .= "<textarea>UNINSTALL SUCCESSFUL\n\n"; $out .= "Make sure you set \$configuration[db_encoding] = 0 in the configuration file.</textarea>"; } } echo $out; }
/** * Removes the mapping between the two objects * @param Object $object * @param Object $object2 * @return */ function RemoveMapping($object, $otherObject = null) { $connection = Database::Connect(); if (is_a($object, "object")) { $this->pog_query = "delete from `objectsiblingmap` where `objectid` = '" . $object->objectId . "'"; if ($otherObject != null && is_a($otherObject, "sibling")) { $this->pog_query .= " and `siblingid` = '" . $otherObject->siblingId . "'"; } } else { if (is_a($object, "sibling")) { $this->pog_query = "delete from `objectsiblingmap` where `siblingid` = '" . $object->siblingId . "'"; if ($otherObject != null && is_a($otherObject, "object")) { $this->pog_query .= " and `objectid` = '" . $otherObject->objectId . "'"; } } } Database::NonQuery($this->pog_query, $connection); }
/** * Deletes a list of objects that match given conditions * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} * @param bool $deep * @return */ function DeleteList($fcv_array, $deep = false, $across = false) { if (sizeof($fcv_array) > 0) { if ($deep || $across) { $objectList = $this->GetList($fcv_array); foreach ($objectList as $object) { $object->Delete($deep, $across); } } else { $connection = Database::Connect(); $pog_query = "delete from `parent_` where "; for ($i = 0, $c = sizeof($fcv_array); $i < $c; $i++) { if (sizeof($fcv_array[$i]) == 1) { $pog_query .= " " . $fcv_array[$i][0] . " "; continue; } else { if ($i > 0 && sizeof($fcv_array[$i - 1]) !== 1) { $pog_query .= " AND "; } if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET') { $pog_query .= "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " '" . $this->Escape($fcv_array[$i][2]) . "'"; } else { $pog_query .= "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " '" . $fcv_array[$i][2] . "'"; } } } return Database::NonQuery($pog_query, $connection); } } }
/** * Deletes a list of objects that match given conditions * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ..} * @param bool $deep * @return */ function DeleteList($fcv_array) { if (sizeof($fcv_array) > 0) { $connection = Database::Connect(); $pog_query = "delete from `plugin` where "; for ($i = 0, $c = sizeof($fcv_array); $i < $c; $i++) { if (sizeof($fcv_array[$i]) == 1) { $pog_query = $pog_query . " " . $fcv_array[$i][0] . " "; continue; } else { if ($i > 0 && sizeof($fcv_array[$i - 1]) !== 1) { $pog_query = $pog_query . " AND "; } if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET') { $pog_query = $pog_query . "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " '" . $this->Escape($fcv_array[$i][2]) . "'"; } else { $pog_query = $pog_query . "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " '" . $fcv_array[$i][2] . "'"; } } } return Database::NonQuery($pog_query, $connection); } }
/** * Unit test for SaveNew() * */ function TestSaveNew($object, $trace = true) { $className = get_class($object); if (!TestSave($object, false)) { if ($trace) { AddTrace("\tSaveNew() ignored"); } return false; } $objectId = $object->SaveNew(false); if ($objectId) { $query = "delete from `" . strtolower($className) . "` where " . strtolower($className) . "Id = '" . $objectId . "';"; $connection = Database::Connect(); Database::NonQuery($query, $connection); if ($trace) { AddTrace("\tSaveNew()....OK!"); } return true; } if ($trace) { AddTrace("\tSaveNew() failed"); AddError("Query failed: " . $object->pog_query); } return false; }