コード例 #1
0
/**
 * edit exp entry 
 *
 * @param integer $id ID of record
 * @global array $kga kimai-global-array
 * @param integer $data  array with new record data
 * @author th
 */
function exp_edit_record($id, $data)
{
    global $kga, $conn;
    $data = clean_data($data);
    $original_array = exp_get_data($id);
    $new_array = array();
    foreach ($original_array as $key => $value) {
        if (isset($data[$key]) == true) {
            $new_array[$key] = $data[$key];
        } else {
            $new_array[$key] = $original_array[$key];
        }
    }
    $values['exp_pctID'] = MySQL::SQLValue($new_array['exp_pctID'], MySQL::SQLVALUE_NUMBER);
    $values['exp_designation'] = MySQL::SQLValue($new_array['exp_designation']);
    $values['exp_comment'] = MySQL::SQLValue($new_array['exp_comment']);
    $values['exp_comment_type'] = MySQL::SQLValue($new_array['exp_comment_type'], MySQL::SQLVALUE_NUMBER);
    $values['exp_timestamp'] = MySQL::SQLValue($new_array['exp_timestamp'], MySQL::SQLVALUE_NUMBER);
    $values['exp_multiplier'] = MySQL::SQLValue($new_array['exp_multiplier'], MySQL::SQLVALUE_NUMBER);
    $values['exp_value'] = MySQL::SQLValue($new_array['exp_value'], MySQL::SQLVALUE_NUMBER);
    $values['exp_refundable'] = MySQL::SQLValue($new_array['exp_refundable'], MySQL::SQLVALUE_NUMBER);
    $filter['exp_ID'] = MySQL::SQLValue($id, MySQL::SQLVALUE_NUMBER);
    $table = $kga['server_prefix'] . "exp";
    $query = MySQL::BuildSQLUpdate($table, $values, $filter);
    $success = true;
    if (!$conn->Query($query)) {
        $success = false;
    }
    if ($success) {
        if (!$conn->TransactionEnd()) {
            $conn->Kill();
        }
    } else {
        if (!$conn->TransactionRollback()) {
            $conn->Kill();
        }
    }
    return $success;
    $original_array = exp_get_data($id);
    $new_array = array();
    foreach ($original_array as $key => $value) {
        if (isset($data[$key]) == true) {
            $new_array[$key] = $data[$key];
        } else {
            $new_array[$key] = $original_array[$key];
        }
    }
}
コード例 #2
0
/**
 * edit exp entry 
 *
 * @param integer $id ID of record
 * @global array $kga kimai-global-array
 * @param integer $data  array with new record data
 * @author th
 */
function exp_edit_record($id, $data)
{
    global $kga;
    global $pdo_conn;
    $p = $kga['server_prefix'];
    $original_array = exp_get_data($id);
    $new_array = array();
    foreach ($original_array as $key => $value) {
        if (isset($data[$key]) == true) {
            $new_array[$key] = $data[$key];
        } else {
            $new_array[$key] = $original_array[$key];
        }
    }
    $pdo_query = $pdo_conn->prepare("UPDATE {$p}exp SET\n    exp_pctID = ?,\n    exp_designation = ?,\n    exp_comment = ?,\n    exp_comment_type = ?,\n    exp_timestamp = ?,\n    exp_multiplier = ?,\n    exp_value = ?,\n    exp_refundable = ?\n    WHERE exp_id = ?;");
    $result = $pdo_query->execute(array($new_array['exp_pctID'], $new_array['exp_designation'], $new_array['exp_comment'], $new_array['exp_comment_type'], $new_array['exp_timestamp'], $new_array['exp_multiplier'], $new_array['exp_value'], $new_array['exp_refundable'], $id));
    if ($result == false) {
        return $result;
    }
    logfile("editrecord:result:" . $result);
}