public function loadArrayByrelationship($searchTerm) { $returnvalue = array(); $operator = "="; // change to a like search if a wildcard character is present if (!(strpos($searchTerm, "%") === false)) { $operator = "like"; } if (!(strpos($searchTerm, "_") === false)) { $operator = "like"; } $sql = "SELECT agentrelationsid FROM agentrelations WHERE relationship {$operator} '{$searchTerm}'"; $preparedsql = "SELECT agentrelationsid FROM agentrelations WHERE relationship {$operator} ? "; if ($statement = $this->conn->prepare($preparedsql)) { $statement->bind_param("s", $searchTerm); $statement->execute(); $statement->bind_result($id); while ($statement->fetch()) { $obj = new agentrelations(); $obj->load($id); $returnvalue[] = $obj; } $statement->close(); } return $returnvalue; }
function deleteAgentRelations($agentrelationsid = NULL) { global $clientRoot; $result = ""; $am = new AgentManager(); if ($am->isAgentEditor()) { if (strlen($agentrelationsid) > 0) { $toDelete = new agentrelations(); $toDelete->setagentrelationsid($agentrelationsid); if ($toDelete->delete()) { $result = "Deleted."; } else { $result = "Error in deleting agent relationships record. " . $toDelete->errorMessage(); } } else { $result = "No agent relationships specified to delete."; } } else { $result = "You aren't authorized to edit agent records."; } return $result; }