[STATIC] Builds a SQL DELETE statement
public static BuildSQLDelete ( string $tableName, array $whereArray = null ) : string | ||
$tableName | string | The name of the table |
$whereArray | array | (Optional) An associative array containing the column names as keys and values as data. The values must be SQL ready (i.e. quotes around strings, formatted dates, ect). If not specified then all values in the table are deleted. |
Результат | string | Returns the SQL DELETE statement |
/** * delete exp entry * * @param integer $usr_ID * @param integer $id -> ID of record * @global array $kga kimai-global-array * @author th */ function exp_delete_record($id) { global $kga, $conn; $filter["exp_ID"] = MySQL::SQLValue($id, MySQL::SQLVALUE_NUMBER); $table = $kga['server_prefix'] . "exp"; $query = MySQL::BuildSQLDelete($table, $filter); return $conn->Query($query); }
/** * delete expense entry * * @param integer $userID * @param integer $id -> ID of record * @global array $kga kimai-global-array * @author th */ function expense_delete($id) { global $kga, $database; $conn = $database->getConnectionHandler(); $filter["expenseID"] = MySQL::SQLValue($id, MySQL::SQLVALUE_NUMBER); $table = $kga['server_prefix'] . "expenses"; $query = MySQL::BuildSQLDelete($table, $filter); return $conn->Query($query); }
/** * @param $membershipRoleID * @return bool */ public function membership_role_delete($membershipRoleID) { $table = $this->kga['server_prefix'] . "membershipRoles"; $filter['membershipRoleID'] = MySQL::SQLValue($membershipRoleID, MySQL::SQLVALUE_NUMBER); $query = MySQL::BuildSQLDelete($table, $filter); $result = $this->conn->Query($query); if ($result == false) { $this->logLastError('membership_role_delete'); return false; } return true; }
$db->Kill(); } // -------------------------------------------------------------------------- // Want to know if you are connected? Use IsConnected() echo "Are we connected? "; var_dump($db->IsConnected()); echo "\n<br />\n"; // -------------------------------------------------------------------------- // Now we can generate SQL statements from arrays! // Let's create an array for the examples // $arrayVariable["column name"] = formatted SQL value $values["Name"] = MySQL::SQLValue("Violet"); $values["Age"] = MySQL::SQLValue(777, MySQL::SQLVALUE_NUMBER); // Echo out some SQL statements echo "<pre>" . "\n"; echo MySQL::BuildSQLDelete("Test", $values) . "\n<br />\n"; echo MySQL::BuildSQLInsert("Test", $values) . "\n<br />\n"; echo MySQL::BuildSQLSelect("Test", $values) . "\n<br />\n"; echo MySQL::BuildSQLUpdate("Test", $values, $values) . "\n<br />\n"; echo MySQL::BuildSQLWhereClause($values) . "\n<br />\n"; echo "</pre>" . "\n"; // Or create more advanced SQL SELECT statements $columns = array("Name", "Age"); $sort = "Name"; $limit = 10; echo MySQL::BuildSQLSelect("Test", $values, $columns, $sort, true, $limit); echo "\n<br />\n"; $columns = array("Color Name" => "Name", "Total Age" => "Age"); $sort = array("Age", "Name"); $limit = "10, 20"; echo MySQL::BuildSQLSelect("Test", $values, $columns, $sort, false, $limit);
function clearTableData($gpx_gr_id, $debug) { global $obj; $obj->execute(MySQL::BuildSQLDelete('grp_page', array('gpx_gr_id' => $obj->getSqlColValue('gpx_gr_id', $gpx_gr_id))), $debug); }
/** * delete exp entry * * @param integer $id -> ID of record * @return object */ public function expense_delete($id) { $filter["expenseID"] = MySQL::SQLValue($id, MySQL::SQLVALUE_NUMBER); $table = $this->getExpenseTable(); $query = MySQL::BuildSQLDelete($table, $filter); return $this->conn->Query($query); }