Example #1
0
/**
 * Delete the records from a table where all the given fields match the given values.
 *
 * @uses $CFG
 * @uses $db
 * @param string $table the table to delete from.
 * @param string $field1 the first field to check (optional).
 * @param string $value1 the value field1 must have (requred if field1 is given, else optional).
 * @param string $field2 the second field to check (optional).
 * @param string $value2 the value field2 must have (requred if field2 is given, else optional).
 * @param string $field3 the third field to check (optional).
 * @param string $value3 the value field3 must have (requred if field3 is given, else optional).
 * @return mixed An ADODB RecordSet object with the results from the SQL call or false.
 */
function delete_records($table, $field1 = null, $value1 = null, $field2 = null, $value2 = null, $field3 = null, $value3 = null)
{
    global $db, $CFG;
    if (defined('ELGG_PERFDB')) {
        global $PERF;
        $PERF->dbqueries++;
    }
    $select = where_clause_prepared($field1, $field2, $field3);
    $values = where_values_prepared($value1, $value2, $value3);
    $stmt = $db->Prepare('DELETE FROM ' . $CFG->prefix . $table . ' ' . $select);
    return $db->Execute($stmt, $values);
}
Example #2
0
/**
 * Delete the records from a table where all the given fields match the given values.
 *
 * @uses $CFG
 * @uses $db
 * @param string $table the table to delete from.
 * @param string $field1 the first field to check (optional).
 * @param string $value1 the value field1 must have (requred if field1 is given, else optional).
 * @param string $field2 the second field to check (optional).
 * @param string $value2 the value field2 must have (requred if field2 is given, else optional).
 * @param string $field3 the third field to check (optional).
 * @param string $value3 the value field3 must have (requred if field3 is given, else optional).
 * @return mixed An ADODB RecordSet object with the results from the SQL call or false.
 */
function delete_records($table, $field1 = null, $value1 = null, $field2 = null, $value2 = null, $field3 = null, $value3 = null)
{
    global $db, $CFG;
    $select = where_clause_prepared($field1, $field2, $field3);
    $values = where_values_prepared($value1, $value2, $value3);
    $stmt = $db->Prepare('DELETE FROM ' . $CFG->prefix . $table . ' ' . $select);
    $returnvalue = $db->Execute($stmt, $values);
    return $returnvalue;
}
/**
 * Delete the records from a table where all the given fields match the given values.
 *
 * @uses $db
 * @param string $table the table to delete from.
 * @param string $field1 the first field to check (optional).
 * @param string $value1 the value field1 must have (requred if field1 is given, else optional).
 * @param string $field2 the second field to check (optional).
 * @param string $value2 the value field2 must have (requred if field2 is given, else optional).
 * @param string $field3 the third field to check (optional).
 * @param string $value3 the value field3 must have (requred if field3 is given, else optional).
 * @return mixed An ADODB RecordSet object with the results from the SQL call or false.
 * @throws SQLException
 */
function delete_records($table, $field1 = null, $value1 = null, $field2 = null, $value2 = null, $field3 = null, $value3 = null)
{
    global $db;
    $select = where_clause_prepared($field1, $field2, $field3);
    $values = where_values_prepared($value1, $value2, $value3);
    $sql = 'DELETE FROM ' . db_table_name($table) . ' ' . $select;
    try {
        $stmt = $db->Prepare($sql);
        increment_perf_db_writes();
        return $db->Execute($stmt, $values);
    } catch (ADODB_Exception $e) {
        throw new SQLException(create_sql_exception_message($e, $sql, $values));
    }
}
Example #4
0
/**
 * Delete the records from a table where all the given fields match the given values.
 *
 * @uses $CFG
 * @uses $db
 * @param string $table the table to delete from.
 * @param string $field1 the first field to check (optional).
 * @param string $value1 the value field1 must have (requred if field1 is given, else optional).
 * @param string $field2 the second field to check (optional).
 * @param string $value2 the value field2 must have (requred if field2 is given, else optional).
 * @param string $field3 the third field to check (optional).
 * @param string $value3 the value field3 must have (requred if field3 is given, else optional).
 * @return mixed An ADODB RecordSet object with the results from the SQL call or false.
 */
function delete_records($table, $field1 = null, $value1 = null, $field2 = null, $value2 = null, $field3 = null, $value3 = null)
{
    global $db, $CFG;
    if (defined('ELGG_PERFDB')) {
        global $PERF;
        $PERF->dbqueries++;
    }
    $select = where_clause_prepared($field1, $field2, $field3);
    $values = where_values_prepared($value1, $value2, $value3);
    $stmt = $db->Prepare('DELETE FROM ' . $CFG->prefix . $table . ' ' . $select);
    $returnvalue = $db->Execute($stmt, $values);
    if ($field1 == "ident") {
        // updating by primary key
        elggcache_delete($table, $field1 . "_" . $value1);
    } else {
        // sledgehammer :(
        elggcache_cachepurgetype($table);
    }
    return $returnvalue;
}