/** * Возвращаем массив записей * * @param $query * @param mysqli $link * * @return array */ function fetchAll($query, mysqli $link) { $result = $link->query($query); if ($link->errno) { SQLFail($query, $link); die; } if ($result->num_rows != 0) { $rows = array(); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { $rows[] = $row; } $result->free(); return $rows; } else { $result->free(); return array(); } }
function startTransaction(mysqli $LINK, $user, $amount, $table) { # занести запись в платежи $query = "INSERT INTO `{$table}`( uid , amount, server_time) VALUES ( " . $LINK->escape_string($user['uid']) . ", '" . $LINK->escape_string($amount) . "', NOW());"; $LINK->query($query); if ($LINK->errno) { #SQLFail($LINK, $query); # debug SQLFail($LINK); die; } return $LINK->insert_id; }