R语言,transactions函数提示“ arguments must have same length” 5C

球球大神指导!在用R语言做关联性分析的时候,transactions函数总是出错!
我的代码是这样的:
library(xlsx)
read.xlsx2(file="C:\Users\18092\Desktop\LL.xlsx",sheetIndex=1)
library(arules)
library(arulesViz)#Load packages
dt<-read.table("C:/Users/18092/Desktop/LL.xlsx",header=T)#import data
LL<-as(dt,"transactions")#convert data.frame to transactions
rules=apriori("C:/Users/18092/Desktop/LL.xlsx",parameter=list(support=0.2,confidence=0.6,minlen=2,maxlen=2))#find association rules
summary(rules)
inspect(x[1:10])#show the first ten rules
错误是这样的:

library(arules)
library(arulesViz)#Load packages
dt<-read.table("C:/Users/18092/Desktop/LL.xlsx",header=T)#import data
Warning messages:
1: In read.table("C:/Users/18092/Desktop/LL.xlsx", header = T) :
line 1 appears to contain embedded nulls
2: In read.table("C:/Users/18092/Desktop/LL.xlsx", header = T) :
incomplete final line found by readTableHeader on 'C:/Users/18092/Desktop/LL.xlsx'
LL<-as(dt,"transactions")#convert data.frame to transactions
Error in tapply(p, x, eval, simplify = FALSE) :
arguments must have same length
rules=apriori("C:/Users/18092/Desktop/LL.xlsx",parameter=list(support=0.2,confidence=0.6,minlen=2,maxlen=2))#find association rules
Error in as(data, "transactions") :
no method or default for coercing “character” to “transactions”
summary(rules)
Error in summary(rules) : object 'rules' not found
#x=sort(subset(rules,subset=1hs%pin%"=TURE"&rhs%pin%"=TRUE"&lift>=1),by="support")#pick out the association needed and sort by support
inspect(x[1:10])#show the first ten rules
Error in inspect(x[1:10]) : object 'x' not found

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
add() argument after * must be an iterable, not Setting pygame编写小游戏时报错

用pygame编写程序时报错,小白求大佬们指点,在线等!! def check_keydown_events(event,ai_settings,screen,ship,bullets): """响应按键""" if event.key == pygame.K_RIGHT: ship.moving_right = True if event.key == pygame.K_LEFT: ship.moving_left = True elif event.key == pygame.K_SPACE: new_bullet = Bullet(ai_settings,screen,ship) bullets.add(new_bullet) File "E:\python\aline_invasion\game_functions.py", line 26, in check_events check_keydown_events(event,ai_settings,screen,ship,bullets) File "E:\python\aline_invasion\game_functions.py", line 11, in check_keydown_events new_bullet = Bullet(ai_settings,screen,ship) File "E:\python\venv\lib\site-packages\pygame\sprite.py", line 124, in __init__ self.add(*groups) File "E:\python\venv\lib\site-packages\pygame\sprite.py", line 142, in add self.add(*group) TypeError: add() argument after * must be an iterable, not Setting

hibernate中nested transactions not supported问题

下边这个方法是struts 中action类中的某个方法,当访问他时: public void fortest(){ Session session = HUtil.getSession(); session.beginTransaction(); // session.flush(); session.getTransaction().commit(); session.beginTransaction(); //session.flush(); session.getTransaction().commit(); /* service.selectRoomCount(room);*/ } 会报告错误:session被关闭了,只好加上session.flush()方法。其中getSession()是获取ThreadLocal的session。 然后就会报告错误nested transactions not supported--不支持嵌套的事物。 原理不清楚,但是解决方法很简单:重新开启一个session,即调用sessionfactory.openSession()方法, 然后在事物提交后关闭session即可。 有没有能解析下原理的大神?

从另一个php文件调用mysqli函数

<div class="post-text" itemprop="text"> <p>I am importing transaction data and saving it into a database. Some of the transaction data has missing fields, so I am manually updating them using the following function from a separate file (file2.php):</p> <pre><code>function categoryRules() { //rules for transactions $sql = "UPDATE Transactions SET cat1 = 'Shops', cat2 = 'Supermarkets and Groceries' WHERE name LIKE '%shipt%'"; if (mysqli_query($conn, $sql)) { echo "SHIPT UPDATE PERFORMED"; } else { echo "Error: " . $sql . "&lt;br&gt;" . mysqli_error($conn); } $sql = "UPDATE Transactions SET cat1 = 'Shops', cat2 = 'Food and Beverage Store', cat3 = 'Beer, Wine and Spirits' WHERE name LIKE '%liquor%'"; if (mysqli_query($conn, $sql)) { echo "LIQUOR UPDATE PERFORMED"; } else { echo "Error: " . $sql . "&lt;br&gt;" . mysqli_error($conn); } $sql = "UPDATE Transactions SET cat1 = 'Service', cat2 = 'Telecommunication Services' WHERE name LIKE '%vzwrls%'"; if (mysqli_query($conn, $sql)) { echo "VERIZON UPDATE PERFORMED"; } else { echo "Error: " . $sql . "&lt;br&gt;" . mysqli_error($conn); } $sql = "UPDATE Transactions SET cat1 = 'Recreation', cat2 = 'Gyms and Fitness Centers' WHERE name LIKE '%classpass%'"; if (mysqli_query($conn, $sql)) { echo "VERIZON UPDATE PERFORMED"; } else { echo "Error: " . $sql . "&lt;br&gt;" . mysqli_error($conn); } } </code></pre> <p>To clean up my code a bit in file1.php, i am calling the file2 function on file 1.php using:</p> <pre><code>$conn = mysqli_connect($host, $user, $pass, $database); if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } include 'categoryRules.php'; categoryRules(); mysqli_close($conn); </code></pre> <p>I am getting the following response when doing so:</p> <blockquote> <p><strong>Error</strong>: UPDATE Transactions SET cat1 = 'Shops', cat2 = 'Supermarkets and Groceries' WHERE name LIKE '%shipt%'</p> <p>Error: UPDATE Transactions SET cat1 = 'Shops', cat2 = 'Supermarkets and Groceries' WHERE name LIKE '%shipt%' </p> <p>Error: UPDATE Transactions SET cat1 = 'Shops', cat2 = 'Food and Beverage Store', cat3 = 'Beer, Wine and Spirits' WHERE name LIKE '%liquor%' </p> <p>Error: UPDATE Transactions SET cat1 = 'Service', cat2 = 'Telecommunication Services' WHERE name LIKE '%vzwrls%' </p> <p>Error: UPDATE Transactions SET cat1 = 'Recreation', cat2 = 'Gyms and Fitness Centers' WHERE name LIKE '%classpass%'</p> </blockquote> <p>It seems like the functions may be running in file 2.php before they get to file1.php, which is where I open, access, and close the database link. Is there a way to import them into file 1? Is there a better way to clean up this portion of the code for file 1.php besides creating file 2.php?</p> </div>

laravel excel3.1 报错提示Unable to resolve NULL driver for [Maatwebsite\Excel\Transactions\TransactionManager]什么原因?

laravel版本:7.6 在使用excel3.1过程中,刚安装好测试导入时出现报错: ![图片说明](https://img-ask.csdn.net/upload/202005/13/1589340785_829665.png) 所有步骤都是按照官方文档进行操作的,运行时就报错。 尝试过重新安装,最后还是这个问题。 代码: ![图片说明](https://img-ask.csdn.net/upload/202005/13/1589340996_867365.png) ![图片说明](https://img-ask.csdn.net/upload/202005/13/1589341051_950087.png) ![图片说明](https://img-ask.csdn.net/upload/202005/13/1589340953_476526.png) 哪位大神可以帮忙解决下吗?

sybase数据库连接出现异常

该方法是用来连接sybase数据库的,有时候执行该是可以的,但是有时候执行该方法就会出现异常: Connection to Sybase server has been lost. All active transactions have been rolled back . 代码: public DataTable ExecuteReader(string query, string connstr) { using (AseConnection conn = new AseConnection(connstr)) { using (AseDataAdapter adapter = new AseDataAdapter(query, conn)) { adapter.SelectCommand.CommandTimeout = 60 * 3; DataTable dt = new DataTable(); adapter.Fill(dt); Command.SQL("Success"); return dt; } } }

sales_order_place_before事件重定向

<div class="post-text" itemprop="text"> <p>I would like on the event <code>sales_order_place_before</code> to make some custom verification and to cancel the placing of the order. What i have tried:</p> <pre><code>public function saleOrderPlaceBefore(Varien_Event_Observer $observer){ if(!VerificationSuccess()){ RemoveProduct(); Mage::throwException(Mage::helper('sales')-&gt;__('Product has expired.')); //how to redirect after error? } } </code></pre> <p>The problem with this approach is that the product is removed from the cart, but the error is shown as an alert box and i would like to redirect the user to some custom page.</p> <p>After this, i tried directly to redirect to a custom page with something like:</p> <pre><code> public function saleOrderPlaceBefore(Varien_Event_Observer $observer){ if(!VerificationSuccess()){ RemoveProduct(); $session = Mage::getSingleton('checkout/session'); $session-&gt;addError(Mage::helper('checkout')-&gt;__("Product expired!")); Mage::app()-&gt;getFrontController()-&gt;getResponse()-&gt;setRedirect(Mage::getUrl('product-error')); Mage::app()-&gt;getResponse()-&gt;sendResponse(); exit; } } </code></pre> <p>Using this code, i receive the error:</p> <pre><code>User Error: Some transactions have not been committed or rolled back in PathToMagento\lib\Varien\Db\Adapter\Pdo\Mysql.php on line 4039 </code></pre> <p>Any ideas on how to manage to cancel the placing of the order, remove the expired product and redirect from this observer(i can use other events also) to a custom page?</p> </div>

关于序列号的问题,Serial Numbers

Problem Description A manufacturer keeps an ordered table of serial numbers by listing in each row of the table a range of serial numbers along with two corresponding pieces of information called the status code and the transfer code. A four-column table stores information about ranges of serial numbers in this order: starting serial number, ending serial number, status code, transfer code. Serial numbers as well as transfer codes are integers from 1 to 2147483647, and status codes are a single upper-case letter. The table is maintained in increasing order of serial numbers, serial number ranges are never allowed to overlap, and for any given serial number, the table must always accurately represent the most recent data (status code and transfer code) for that serial number. Let's say that 100,000 serial numbers are created with a status of "A" and a transfer code of "1". An entry for those serial numbers might look like this: 1 100000 A 1 This is obviously far more efficient than storing 100,000 individual rows all with the same status and transfer codes. The challenge arises when serial numbers within already defined ranges need to be given different status or transfer codes. For example, if serial number 12345 needs to change to status B, the above table would need to become three separate entries: 1 12344 A 1 12345 12345 B 1 12346 100000 A 1 Now let's change the transfer code of all serial numbers in the range 12000 to 12999 to 2. This gets us: 1 11999 A 1 12000 12344 A 2 12345 12345 B 2 12346 12999 A 2 13000 100000 A 1 Now change all existing serial numbers from 10000 to 100000 to status C and transfer code 2: 1 9999 A 1 10000 100000 C 2 Once created a serial number will never be deleted, but it is possible to have ranges of undefined serial numbers between ranges of defined ones. To demonstrate, let's now set all serial numbers from 1000000 to 1999999 to status Z and transfer code 99: 1 9999 A 1 10000 100000 C 2 1000000 1999999 Z 99 Finally, the table is always maintained with a minimal number of rows, meaning specifically that there will never be two adjacent rows in the table where one would suffice. For example, consider the following serial number table: 1 10 A 1 11 20 A 1 21 30 B 1 The first two rows could actually be represented by a single row, meaning that the table above does not have a minimal number of rows. The same data represented by a minimal number of rows would look like this: 1 20 A 1 21 30 B 1 The following table, however, because the first two rows have non-matching transfer codes, already contains the minimal number of rows: 1 10 A 1 11 20 A 2 21 30 B 1 Similarly, the following table cannot be reduced further because the first two rows do not represent a continuous series of serial numbers: 1 10 A 1 12 20 A 1 21 30 B 1 Input Each input case begins with a single line that is a character string naming the test case. This string contains at most 80 characters. The name "END" marks the end of the input. Following this will be 1 to 100 lines of the form "A B S T", where A, B, and T are integers in the range 1 to 231-1, S is an uppercase letter, and A<=B. These lines are, in the order they are to be applied, the serial number transactions to be recorded, where A is the start of the serial number range, B is the end of the serial number range, S is the status code, and T is the transfer code. The list of serial number transactions is terminated by a line containing only a 0 (zero) character. Output For each input case, echo the test case name to the output on a line by itself, followed by the resulting minimal-rows serial number table that results after all serial number transactions have been applied. Sample Input First Example 1 100000 A 1 12345 12345 B 1 0 And Another 1 100000 A 1 12345 12345 B 1 12000 12999 A 2 12345 12345 B 2 0 Test Case Three 1 100000 A 1 12345 12345 B 1 12000 12999 A 2 12345 12345 B 2 10000 100000 C 2 0 Example Four 1 100000 A 1 12345 12345 B 1 12000 12999 A 2 12345 12345 B 2 10000 100000 C 2 1000000 1999999 Z 99 0 Example 5 1 10 A 1 21 30 B 1 11 20 A 1 0 Example 6 21 30 B 1 1 10 A 1 11 20 A 2 0 Example 7 12 20 A 1 21 30 B 1 1 10 A 1 0 END Sample Output First Example 1 12344 A 1 12345 12345 B 1 12346 100000 A 1 And Another 1 11999 A 1 12000 12344 A 2 12345 12345 B 2 12346 12999 A 2 13000 100000 A 1 Test Case Three 1 9999 A 1 10000 100000 C 2 Example Four 1 9999 A 1 10000 100000 C 2 1000000 1999999 Z 99 Example 5 1 20 A 1 21 30 B 1 Example 6 1 10 A 1 11 20 A 2 21 30 B 1 Example 7 1 10 A 1 12 20 A 1 21 30 B 1

序列号怎么算,Serial Numbers

Problem Description A manufacturer keeps an ordered table of serial numbers by listing in each row of the table a range of serial numbers along with two corresponding pieces of information called the status code and the transfer code. A four-column table stores information about ranges of serial numbers in this order: starting serial number, ending serial number, status code, transfer code. Serial numbers as well as transfer codes are integers from 1 to 2147483647, and status codes are a single upper-case letter. The table is maintained in increasing order of serial numbers, serial number ranges are never allowed to overlap, and for any given serial number, the table must always accurately represent the most recent data (status code and transfer code) for that serial number. Let's say that 100,000 serial numbers are created with a status of "A" and a transfer code of "1". An entry for those serial numbers might look like this: 1 100000 A 1 This is obviously far more efficient than storing 100,000 individual rows all with the same status and transfer codes. The challenge arises when serial numbers within already defined ranges need to be given different status or transfer codes. For example, if serial number 12345 needs to change to status B, the above table would need to become three separate entries: 1 12344 A 1 12345 12345 B 1 12346 100000 A 1 Now let's change the transfer code of all serial numbers in the range 12000 to 12999 to 2. This gets us: 1 11999 A 1 12000 12344 A 2 12345 12345 B 2 12346 12999 A 2 13000 100000 A 1 Now change all existing serial numbers from 10000 to 100000 to status C and transfer code 2: 1 9999 A 1 10000 100000 C 2 Once created a serial number will never be deleted, but it is possible to have ranges of undefined serial numbers between ranges of defined ones. To demonstrate, let's now set all serial numbers from 1000000 to 1999999 to status Z and transfer code 99: 1 9999 A 1 10000 100000 C 2 1000000 1999999 Z 99 Finally, the table is always maintained with a minimal number of rows, meaning specifically that there will never be two adjacent rows in the table where one would suffice. For example, consider the following serial number table: 1 10 A 1 11 20 A 1 21 30 B 1 The first two rows could actually be represented by a single row, meaning that the table above does not have a minimal number of rows. The same data represented by a minimal number of rows would look like this: 1 20 A 1 21 30 B 1 The following table, however, because the first two rows have non-matching transfer codes, already contains the minimal number of rows: 1 10 A 1 11 20 A 2 21 30 B 1 Similarly, the following table cannot be reduced further because the first two rows do not represent a continuous series of serial numbers: 1 10 A 1 12 20 A 1 21 30 B 1 Input Each input case begins with a single line that is a character string naming the test case. This string contains at most 80 characters. The name "END" marks the end of the input. Following this will be 1 to 100 lines of the form "A B S T", where A, B, and T are integers in the range 1 to 231-1, S is an uppercase letter, and A<=B. These lines are, in the order they are to be applied, the serial number transactions to be recorded, where A is the start of the serial number range, B is the end of the serial number range, S is the status code, and T is the transfer code. The list of serial number transactions is terminated by a line containing only a 0 (zero) character. Output For each input case, echo the test case name to the output on a line by itself, followed by the resulting minimal-rows serial number table that results after all serial number transactions have been applied. Sample Input First Example 1 100000 A 1 12345 12345 B 1 0 And Another 1 100000 A 1 12345 12345 B 1 12000 12999 A 2 12345 12345 B 2 0 Test Case Three 1 100000 A 1 12345 12345 B 1 12000 12999 A 2 12345 12345 B 2 10000 100000 C 2 0 Example Four 1 100000 A 1 12345 12345 B 1 12000 12999 A 2 12345 12345 B 2 10000 100000 C 2 1000000 1999999 Z 99 0 Example 5 1 10 A 1 21 30 B 1 11 20 A 1 0 Example 6 21 30 B 1 1 10 A 1 11 20 A 2 0 Example 7 12 20 A 1 21 30 B 1 1 10 A 1 0 END Sample Output First Example 1 12344 A 1 12345 12345 B 1 12346 100000 A 1 And Another 1 11999 A 1 12000 12344 A 2 12345 12345 B 2 12346 12999 A 2 13000 100000 A 1 Test Case Three 1 9999 A 1 10000 100000 C 2 Example Four 1 9999 A 1 10000 100000 C 2 1000000 1999999 Z 99 Example 5 1 20 A 1 21 30 B 1 Example 6 1 10 A 1 11 20 A 2 21 30 B 1 Example 7 1 10 A 1 12 20 A 1 21 30 B 1

数据库中的 Transactions 不能执行

我使用下面的代码,遇到些问题: mDb.beginTransaction(); String updateQuery ="Query entered here"; String[] valVars = { Variables initialized here }; Cursor c = mDb.rawQuery(updateQuery, valVars); if (c != null) { mDb.setTransactionSuccessful(); mDb.endTransaction(); return true; } else { mDb.endTransaction(); return false; } 当我调试的时候 return true,但在其余的状态下就 return false 。如何处理这个问题?

Line & Circle Maze 迷宫的问题

Problem Description A manufacturer keeps an ordered table of serial numbers by listing in each row of the table a range of serial numbers along with two corresponding pieces of information called the status code and the transfer code. A four-column table stores information about ranges of serial numbers in this order: starting serial number, ending serial number, status code, transfer code. Serial numbers as well as transfer codes are integers from 1 to 2147483647, and status codes are a single upper-case letter. The table is maintained in increasing order of serial numbers, serial number ranges are never allowed to overlap, and for any given serial number, the table must always accurately represent the most recent data (status code and transfer code) for that serial number. Let's say that 100,000 serial numbers are created with a status of "A" and a transfer code of "1". An entry for those serial numbers might look like this: 1 100000 A 1 This is obviously far more efficient than storing 100,000 individual rows all with the same status and transfer codes. The challenge arises when serial numbers within already defined ranges need to be given different status or transfer codes. For example, if serial number 12345 needs to change to status B, the above table would need to become three separate entries: 1 12344 A 1 12345 12345 B 1 12346 100000 A 1 Now let's change the transfer code of all serial numbers in the range 12000 to 12999 to 2. This gets us: 1 11999 A 1 12000 12344 A 2 12345 12345 B 2 12346 12999 A 2 13000 100000 A 1 Now change all existing serial numbers from 10000 to 100000 to status C and transfer code 2: 1 9999 A 1 10000 100000 C 2 Once created a serial number will never be deleted, but it is possible to have ranges of undefined serial numbers between ranges of defined ones. To demonstrate, let's now set all serial numbers from 1000000 to 1999999 to status Z and transfer code 99: 1 9999 A 1 10000 100000 C 2 1000000 1999999 Z 99 Finally, the table is always maintained with a minimal number of rows, meaning specifically that there will never be two adjacent rows in the table where one would suffice. For example, consider the following serial number table: 1 10 A 1 11 20 A 1 21 30 B 1 The first two rows could actually be represented by a single row, meaning that the table above does not have a minimal number of rows. The same data represented by a minimal number of rows would look like this: 1 20 A 1 21 30 B 1 The following table, however, because the first two rows have non-matching transfer codes, already contains the minimal number of rows: 1 10 A 1 11 20 A 2 21 30 B 1 Similarly, the following table cannot be reduced further because the first two rows do not represent a continuous series of serial numbers: 1 10 A 1 12 20 A 1 21 30 B 1 Input Each input case begins with a single line that is a character string naming the test case. This string contains at most 80 characters. The name "END" marks the end of the input. Following this will be 1 to 100 lines of the form "A B S T", where A, B, and T are integers in the range 1 to 231-1, S is an uppercase letter, and A<=B. These lines are, in the order they are to be applied, the serial number transactions to be recorded, where A is the start of the serial number range, B is the end of the serial number range, S is the status code, and T is the transfer code. The list of serial number transactions is terminated by a line containing only a 0 (zero) character. Output For each input case, echo the test case name to the output on a line by itself, followed by the resulting minimal-rows serial number table that results after all serial number transactions have been applied. Sample Input First Example 1 100000 A 1 12345 12345 B 1 0 And Another 1 100000 A 1 12345 12345 B 1 12000 12999 A 2 12345 12345 B 2 0 Test Case Three 1 100000 A 1 12345 12345 B 1 12000 12999 A 2 12345 12345 B 2 10000 100000 C 2 0 Example Four 1 100000 A 1 12345 12345 B 1 12000 12999 A 2 12345 12345 B 2 10000 100000 C 2 1000000 1999999 Z 99 0 Example 5 1 10 A 1 21 30 B 1 11 20 A 1 0 Example 6 21 30 B 1 1 10 A 1 11 20 A 2 0 Example 7 12 20 A 1 21 30 B 1 1 10 A 1 0 END Sample Output First Example 1 12344 A 1 12345 12345 B 1 12346 100000 A 1 And Another 1 11999 A 1 12000 12344 A 2 12345 12345 B 2 12346 12999 A 2 13000 100000 A 1 Test Case Three 1 9999 A 1 10000 100000 C 2 Example Four 1 9999 A 1 10000 100000 C 2 1000000 1999999 Z 99 Example 5 1 20 A 1 21 30 B 1 Example 6 1 10 A 1 11 20 A 2 21 30 B 1 Example 7 1 10 A 1 12 20 A 1 21 30 B 1

sql查询放到php函数

<div class="post-text" itemprop="text"> <p>I have a <code>if/else</code> condition in <code>Yii Framework</code>. When the user is admin the database query should not have a filter and if the user is not admin the database query should have a filter.</p> <p></p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code> if($ut=='Admin'){ // if the user is Admin the query should not have a filter $queryCustomer = Yii::app()-&gt;db-&gt;createCommand() -&gt;select('cust.mobile_number as customer,sum(trans.price) as sales,trans.datetime') -&gt;from('customers cust') -&gt;join('transactions trans', 'cust.id=trans.customer_id') -&gt;where('transaction_type_id=:id', array(':id'=&gt;1)) -&gt;group('customer_id') -&gt;order('trans.datetime DESC') -&gt;queryAll(); $per_customer=$this-&gt;renderTableCustomer($queryCustomer); } else { // if the user is not Admin the query should have a filter $queryCustomer = Yii::app()-&gt;db-&gt;createCommand() -&gt;select('cust.mobile_number as customer,sum(trans.price) as sales,trans.datetime') -&gt;from('customers cust') -&gt;join('transactions trans', 'cust.id=trans.customer_id') -&gt;where('transaction_type_id=:id', array(':id'=&gt;1)) -&gt;andWhere('user_id=:userID',array(':userID'=&gt;$filter)) -&gt;group('customer_id') -&gt;order('trans.datetime DESC') -&gt;queryAll(); $per_customer=$this-&gt;renderTableCustomer($queryCustomer);</code></pre> </div> </div> <p>The queries is the same except I added a where statement in else query. Since the query is same, is there a possibility to put it on a function and when I call it I will add the where statement as a parameter? </p> </div>

金额的计算的问题,Loan

Description Mr. Smith received a loan for Q dollars. He plans to pay off this loan in K years at an interest rate of P percent per year. That means that, after each year, Mr. Smith's debt grows by P*Q'/100 dollars (Q' being the debt at the beginning of that year) and his annual payment is deducted from his debt. For the first year, Mr. Smith wants to pay minimal amount that will allow him to pay off the loan within exactly K years. For each subsequent year, he is willing to pay either the same amount as the previous year or one cent less than the previous year's payment. He wants the loan to be completely paid off without overpayment of even a single cent by the end of the Kth year. The bank performs all transactions with a precision of one cent, and calculates interest due at the end of each year. Whenever interest is calculated, the result is immediately rounded to the nearest cent, with 0.5 cents rounded up. Input The input contains a single line with three numbers Q, P and K, separated by spaces. Q is a real number (10 <= Q <= 1000000) given with no more than two digits to the right of the decimal point. This value represents the amount of the loan in dollars. One one-hundredth of a dollar is a cent. P and K are integers (0 <= P <= 100, 1 <= K <= 100). Output Write to the output file a schedule of payments for Mr. Smith. You should write the amount of each payment and number of years that payment should be made, thus effectively grouping equal payments. Each group of equal payments must be written on separate line, with no blank lines between them. The output format for each group of payments is: $X for Y year(s) where X is payment amount in dollars printed with exactly two digits after decimal point. Y is a number of years for which this payment should be made. The dollar value given on each line must be one cent less than the dollar value printed above it. If there are multiple correct payment schedules, you can output any one of them, but the first payment should be the minimal possible one. If no solution can be found for the given input, then the output file shall contain only the word "Impossible". Sample Input 939850.83 85 35 Sample Output $798873.22 for 1 year(s) $798873.21 for 1 year(s) $798873.20 for 1 year(s) $798873.19 for 1 year(s) $798873.18 for 1 year(s) $798873.17 for 4 year(s) $798873.16 for 1 year(s) $798873.15 for 2 year(s) $798873.14 for 1 year(s) $798873.13 for 3 year(s) $798873.12 for 1 year(s) $798873.11 for 4 year(s) $798873.10 for 2 year(s) $798873.09 for 7 year(s) $798873.08 for 2 year(s) $798873.07 for 1 year(s) $798873.06 for 1 year(s) $798873.05 for 1 year(s)

Serial Numbers 关于序列号的问题

Problem Description A manufacturer keeps an ordered table of serial numbers by listing in each row of the table a range of serial numbers along with two corresponding pieces of information called the status code and the transfer code. A four-column table stores information about ranges of serial numbers in this order: starting serial number, ending serial number, status code, transfer code. Serial numbers as well as transfer codes are integers from 1 to 2147483647, and status codes are a single upper-case letter. The table is maintained in increasing order of serial numbers, serial number ranges are never allowed to overlap, and for any given serial number, the table must always accurately represent the most recent data (status code and transfer code) for that serial number. Let's say that 100,000 serial numbers are created with a status of "A" and a transfer code of "1". An entry for those serial numbers might look like this: 1 100000 A 1 This is obviously far more efficient than storing 100,000 individual rows all with the same status and transfer codes. The challenge arises when serial numbers within already defined ranges need to be given different status or transfer codes. For example, if serial number 12345 needs to change to status B, the above table would need to become three separate entries: 1 12344 A 1 12345 12345 B 1 12346 100000 A 1 Now let's change the transfer code of all serial numbers in the range 12000 to 12999 to 2. This gets us: 1 11999 A 1 12000 12344 A 2 12345 12345 B 2 12346 12999 A 2 13000 100000 A 1 Now change all existing serial numbers from 10000 to 100000 to status C and transfer code 2: 1 9999 A 1 10000 100000 C 2 Once created a serial number will never be deleted, but it is possible to have ranges of undefined serial numbers between ranges of defined ones. To demonstrate, let's now set all serial numbers from 1000000 to 1999999 to status Z and transfer code 99: 1 9999 A 1 10000 100000 C 2 1000000 1999999 Z 99 Finally, the table is always maintained with a minimal number of rows, meaning specifically that there will never be two adjacent rows in the table where one would suffice. For example, consider the following serial number table: 1 10 A 1 11 20 A 1 21 30 B 1 The first two rows could actually be represented by a single row, meaning that the table above does not have a minimal number of rows. The same data represented by a minimal number of rows would look like this: 1 20 A 1 21 30 B 1 The following table, however, because the first two rows have non-matching transfer codes, already contains the minimal number of rows: 1 10 A 1 11 20 A 2 21 30 B 1 Similarly, the following table cannot be reduced further because the first two rows do not represent a continuous series of serial numbers: 1 10 A 1 12 20 A 1 21 30 B 1 Input Each input case begins with a single line that is a character string naming the test case. This string contains at most 80 characters. The name "END" marks the end of the input. Following this will be 1 to 100 lines of the form "A B S T", where A, B, and T are integers in the range 1 to 231-1, S is an uppercase letter, and A<=B. These lines are, in the order they are to be applied, the serial number transactions to be recorded, where A is the start of the serial number range, B is the end of the serial number range, S is the status code, and T is the transfer code. The list of serial number transactions is terminated by a line containing only a 0 (zero) character. Output For each input case, echo the test case name to the output on a line by itself, followed by the resulting minimal-rows serial number table that results after all serial number transactions have been applied. Sample Input First Example 1 100000 A 1 12345 12345 B 1 0 And Another 1 100000 A 1 12345 12345 B 1 12000 12999 A 2 12345 12345 B 2 0 Test Case Three 1 100000 A 1 12345 12345 B 1 12000 12999 A 2 12345 12345 B 2 10000 100000 C 2 0 Example Four 1 100000 A 1 12345 12345 B 1 12000 12999 A 2 12345 12345 B 2 10000 100000 C 2 1000000 1999999 Z 99 0 Example 5 1 10 A 1 21 30 B 1 11 20 A 1 0 Example 6 21 30 B 1 1 10 A 1 11 20 A 2 0 Example 7 12 20 A 1 21 30 B 1 1 10 A 1 0 END Sample Output First Example 1 12344 A 1 12345 12345 B 1 12346 100000 A 1 And Another 1 11999 A 1 12000 12344 A 2 12345 12345 B 2 12346 12999 A 2 13000 100000 A 1 Test Case Three 1 9999 A 1 10000 100000 C 2 Example Four 1 9999 A 1 10000 100000 C 2 1000000 1999999 Z 99 Example 5 1 20 A 1 21 30 B 1 Example 6 1 10 A 1 11 20 A 2 21 30 B 1 Example 7 1 10 A 1 12 20 A 1 21 30 B 1

将html表数据传递给函数

<div class="post-text" itemprop="text"> <p>I've used this site a ton but this is the first time posting. Please be kind. I'm trying to pass data from an HTML table to a function using onclick. I'm able to pass the entire table using <code>onclick="markPaid(transaction.innterText)</code>, but I want to be able to pass the data from the current data row only. My best attempt is <code>onclick="markPaid(thistransaction.innterText)"</code>but results in an undefined variable when passed to the function "markPaid". Hopefully this is a clear explanation of the issue. </p> <pre><code> &lt;table id ="transaction" border="1"&gt; &lt;style&gt;th, td {padding: 10px;}&lt;/style&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;&lt;?php echo implode('&lt;/th&gt;&lt;th&gt;', array_keys(current($transactions))); ?&gt;&lt;/th&gt; &lt;th&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;?php foreach ($transactions as $transaction): array_map('htmlentities', $transaction); ?&gt; &lt;tr&gt; &lt;td id = "thistransaction"&gt;&lt;?php echo implode('&lt;/td&gt;&lt;td&gt;', $transaction); ?&gt;&lt;/td&gt; &lt;td&gt;&lt;a class ="btn btn-default" href="invoice.php?ID=&lt;?php echo $transaction['transid']; ?&gt;" target = "_blank"&gt;Print Invoice&lt;/a&gt; &lt;/td&gt; &lt;?php if($transaction['paid'] == false): ?&gt; &lt;td&gt;&lt;button class = "btn btn-default" onclick="markPaid(thistransaction.innterText)"&gt;Mark as Paid&lt;/button&gt;&lt;/td&gt; &lt;?php endif; ?&gt; &lt;/tr&gt; &lt;?php endforeach; ?&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> </div>

软件登录时提示System.NullReferenceException未被引用到实例

![图片说明](https://img-ask.csdn.net/upload/201904/19/1555644735_976122.png) 测试了很多电脑大部分可以登录,个别电脑登录时提示这个错误,重新装了NET插件和Access数据库还是不行,本人完全菜鸟一枚求大神帮帮忙啊,解决不了急死了~~~~ ee the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** ee the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object. at Emergency.Module.setControls(Single newx, Single newy, Control cons) in d:\Users\Desktop\站务中心应急辅助系统测试版\Emergency\Class\Module.cs:line 2944 at Emergency.FormMain.FormMain_Resize(Object sender, EventArgs e) in d:\Users\Desktop\站务中心应急辅助系统测试版\Emergency\DataForm\FormMain.cs:line 49 at System.Windows.Forms.Control.OnResize(EventArgs e) at System.Windows.Forms.Form.OnResize(EventArgs e) at System.Windows.Forms.Control.OnSizeChanged(EventArgs e) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height) at System.Windows.Forms.Control.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) at System.Windows.Forms.Form.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) at System.Windows.Forms.Control.ScaleControl(SizeF factor, BoundsSpecified specified) at System.Windows.Forms.ScrollableControl.ScaleControl(SizeF factor, BoundsSpecified specified) at System.Windows.Forms.Form.ScaleControl(SizeF factor, BoundsSpecified specified) at System.Windows.Forms.Control.ScaleControl(SizeF includedFactor, SizeF excludedFactor, Control requestingControl) at System.Windows.Forms.ContainerControl.Scale(SizeF includedFactor, SizeF excludedFactor, Control requestingControl) at System.Windows.Forms.ContainerControl.PerformAutoScale(Boolean includedBounds, Boolean excludedBounds) at System.Windows.Forms.ContainerControl.PerformNeededAutoScaleOnLayout() at System.Windows.Forms.ContainerControl.OnLayoutResuming(Boolean performLayout) at System.Windows.Forms.Control.ResumeLayout(Boolean performLayout) at Emergency.FormMain.InitializeComponent() in d:\Users\Desktop\站务中心应急辅助系统测试版\Emergency\DataForm\FormMain.Designer.cs:line 2355 at Emergency.FormMain..ctor() in d:\Users\Desktop\站务中心应急辅助系统测试版\Emergency\DataForm\FormMain.cs:line 17 at Emergency.FormLogin.button1_Click(Object sender, EventArgs e) in d:\Users\Desktop\站务中心应急辅助系统测试版\Emergency\DataForm\FormLogin.cs:line 47 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) ************** Loaded Assemblies ************** mscorlib Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll ---------------------------------------- Emergency Assembly Version: 1.0.0.0 Win32 Version: 1.0.0.0 CodeBase: file:///G:/%E9%99%84%E4%BB%B61%EF%BC%9A%E5%BA%94%E6%80%A5%E8%BE%85%E5%8A%A9%E7%B3%BB%E7%BB%9FV1.0%E5%AE%89%E8%A3%85%E5%8C%85/%E5%BA%94%E6%80%A5%E8%BE%85%E5%8A%A9%E7%B3%BB%E7%BB%9FV1.0%E5%AE%89%E8%A3%85%E5%8C%85/%E5%BA%94%E6%80%A5%E8%BE%85%E5%8A%A9%E7%B3%BB%E7%BB%9FV1.0/%E5%BA%94%E6%80%A5%E8%BE%85%E5%8A%A9%E7%B3%BB%E7%BB%9FV1.0.exe ---------------------------------------- System.Windows.Forms Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ---------------------------------------- System.Drawing Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll ---------------------------------------- System Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.Data Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll ---------------------------------------- System.Core Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll ---------------------------------------- System.Transactions Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll ---------------------------------------- System.EnterpriseServices Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll ---------------------------------------- System.Configuration Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll ---------------------------------------- System.Xml Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll ---------------------------------------- ************** JIT Debugging ************** To enable just-in-time (JIT) debugging, the .config file for this application or computer (machine.config) must have the jitDebugging value set in the system.windows.forms section.: Object reference not set to an instance of an object. at Emergency.Module.setControls(Single newx, Single newy, Control cons) in d:\Users\Desktop\站务中心应急辅助系统测试版\Emergency\Class\Module.cs:line 2944 at Emergency.FormMain.FormMain_Resize(Object sender, EventArgs e) in d:\Users\Desktop\站务中心应急辅助系统测试版\Emergency\DataForm\FormMain.cs:line 49 at System.Windows.Forms.Control.OnResize(EventArgs e) at System.Windows.Forms.Form.OnResize(EventArgs e) at System.Windows.Forms.Control.OnSizeChanged(EventArgs e) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height) at System.Windows.Forms.Control.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) at System.Windows.Forms.Form.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) at System.Windows.Forms.Control.ScaleControl(SizeF factor, BoundsSpecified specified) at System.Windows.Forms.ScrollableControl.ScaleControl(SizeF factor, BoundsSpecified specified) at System.Windows.Forms.Form.ScaleControl(SizeF factor, BoundsSpecified specified) at System.Windows.Forms.Control.ScaleControl(SizeF includedFactor, SizeF excludedFactor, Control requestingControl) at System.Windows.Forms.ContainerControl.Scale(SizeF includedFactor, SizeF excludedFactor, Control requestingControl) at System.Windows.Forms.ContainerControl.PerformAutoScale(Boolean includedBounds, Boolean excludedBounds) at System.Windows.Forms.ContainerControl.PerformNeededAutoScaleOnLayout() at System.Windows.Forms.ContainerControl.OnLayoutResuming(Boolean performLayout) at System.Windows.Forms.Control.ResumeLayout(Boolean performLayout) at Emergency.FormMain.InitializeComponent() in d:\Users\Desktop\站务中心应急辅助系统测试版\Emergency\DataForm\FormMain.Designer.cs:line 2355 at Emergency.FormMain..ctor() in d:\Users\Desktop\站务中心应急辅助系统测试版\Emergency\DataForm\FormMain.cs:line 17 at Emergency.FormLogin.button1_Click(Object sender, EventArgs e) in d:\Users\Desktop\站务中心应急辅助系统测试版\Emergency\DataForm\FormLogin.cs:line 47 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) ************** Loaded Assemblies ************** mscorlib Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll ---------------------------------------- Emergency Assembly Version: 1.0.0.0 Win32 Version: 1.0.0.0 CodeBase: file:///G:/%E9%99%84%E4%BB%B61%EF%BC%9A%E5%BA%94%E6%80%A5%E8%BE%85%E5%8A%A9%E7%B3%BB%E7%BB%9FV1.0%E5%AE%89%E8%A3%85%E5%8C%85/%E5%BA%94%E6%80%A5%E8%BE%85%E5%8A%A9%E7%B3%BB%E7%BB%9FV1.0%E5%AE%89%E8%A3%85%E5%8C%85/%E5%BA%94%E6%80%A5%E8%BE%85%E5%8A%A9%E7%B3%BB%E7%BB%9FV1.0/%E5%BA%94%E6%80%A5%E8%BE%85%E5%8A%A9%E7%B3%BB%E7%BB%9FV1.0.exe ---------------------------------------- System.Windows.Forms Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ---------------------------------------- System.Drawing Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll ---------------------------------------- System Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.Data Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll ---------------------------------------- System.Core Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll ---------------------------------------- System.Transactions Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll ---------------------------------------- System.EnterpriseServices Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll ---------------------------------------- System.Configuration Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll ---------------------------------------- System.Xml Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll ---------------------------------------- ************** JIT Debugging ************** To enable just-in-time (JIT) debugging, the .config file for this application or computer (machine.config) must have the jitDebugging value set in the system.windows.forms section.

使用API​​ /函数调用或执行Cron Job方法 - 查询处理事务 - 您将如何处理它?

<div class="post-text" itemprop="text"> <p>I wanted to run something by you guys. I am starting a new project which is roughly the following:</p> <p>Important information: I am using PHP and MySQL</p> <p>Every minute I get a list of to-do transactions from an API from different users. </p> <p>Example: </p> <pre><code>user1 send $1 to user2 userx send $2 to usera userw send $0.50 to user2 etc.. </code></pre> <p>Lets say user1 wants to send $1 to user2. There are two posibilities, it's succesful or it's unsuccessful because there are insufficient funds or the user spelled the username wrong. If it's unsuccesfull I send out a message to the user.</p> <p>I am now facing several options - please bare with me through my thought process.</p> <p><strong>Option 1</strong></p> <p>Create a database table with transactions that need to be processed and use a cronjob that processes them every minute. The risk here is that the script could run against an error or a timeout and the other transactions would still show In Progress in the database table. So I would need a second script to check that against a timestamp.</p> <p><strong>Option 2</strong></p> <p>Create an API or Function which gets called for each transaction after I receive them and brings me a response. From which then I can call another API or Function to deal with that response or move on to the next transaction. However I would still have to put them in a database table since I can't risk losing them if the script stops executing. So it would work as follow: put all transactions in database table - start transaction - when finished transaction delete from table - start transaction 2.</p> <hr> <p><em>Both options are flawed because you don't know how long the list of transactions will be. If it's long PHP is definitely not optimal to run for a long time - using set timeout to zero is risky. I am looking to create a solution that will scale with PHP. So I was thinking about an Option 3.</em></p> <hr> <p><strong>Option 3 (Optimal solution?)</strong></p> <p>Use an API to return 10 transactions. </p> <p>In database set a flag to say they are sent to a script and timestamp to say when they were sent</p> <p>PHP script retreives 10 transactions from API - handles 10 transactions.</p> <p>Once transaction completed - delete it from this table and copy it to completed transaction table.</p> <p>Have a cronjob script check every 3 minutes if timesent is greater then X minutes (based on an upper bound of the execution time of 10 transactions). If it is greater - set them to not sent - so they can be sent out again.</p> <hr> <p>As you can see I wrote down my whole thought process on this and am looking for input. There's bound to be stuff that I missed. Also please realize that these are not real financial transactions - it's just the best metafore I could use to make it clear.</p> <p>Thank you very much,</p> <p>Ice</p> </div>

使用php查询帐户运行余额

<div class="post-text" itemprop="text"> <p>Please assist, how to write php code for the following query:</p> <pre><code>SELECT transactions_id, trn_date, trn_dt_total, trn_ct_total, trn_description, trn_bank_reference, balance FROM (SELECT t.*, @n := IF(@g &lt;&gt; transactions_id, 0, @n) + COALESCE(trn_dt_total,0) - COALESCE(trn_ct_total, 0) balance, @g := transactions_id FROM transactions t, (SELECT @n := 0) n, (SELECT @g := 0) g WHERE trn_building_id = 1 and trn_unit_id = 1 and trn_tenant_id = 1 ORDER BY transactions_id, trn_date) query </code></pre> <p>My php page query</p> <pre><code>$details = $db-&gt;query(); </code></pre> <p>When running the query in MySql without the "query" line i get the error:</p> <pre><code>1248 - Every derived table must have its own alias </code></pre> </div>

尝试catch,以及多个mysql insert语句。 它会接受全部还是否认所有疑问?

<div class="post-text" itemprop="text"> <p>Hey I have question to you guys. If I implement my sql mysql insert in try catch will that prevent from executing only partial INSERT into database if one of them will fail ?</p> <pre><code>try { //SQL INSET TABLE 1 //SQL INSET TABLE 2 //SQL INSET TABLE 3 //SQL INSET TABLE 4 } catch(Exception $e) {...} </code></pre> <p>I would like to deny all or accept all. Is that they way to do that? </p> <p>Regarding to your comment. I am using PDO. I would be grateful for the configuration example that would allow that.</p> <p>In Your comments you often recommending transaction and rollback. Can anyone give an example with some comments on the code? x</p> <p>I would also like to know if there is some alternative ways of achieving this effect.</p> <p>@SOLUTION FOUND AT: <a href="https://stackoverflow.com/questions/2708237/php-mysql-transactions-examples">PHP + MySQL transactions examples</a>: </p> <pre><code>try { // First of all, let's begin a transaction $db-&gt;beginTransaction(); // A set of queries; if one fails, an exception should be thrown $db-&gt;query('first query'); $db-&gt;query('second query'); $db-&gt;query('third query'); // If we arrive here, it means that no exception was thrown // i.e. no query has failed, and we can commit the transaction $db-&gt;commit(); } catch (Exception $e) { // An exception has been thrown // We must rollback the transaction $db-&gt;rollback(); } </code></pre> <p>Note that, with this idea, if a query fails, an Exception must be thrown:</p> <p>PDO can do that, depending on how you configure it See PDO::setAttribute and PDO::ATTR_ERRMODE and PDO::ERRMODE_EXCEPTION else, with some other API, you might have to test the result of the function used to execute a query, and throw an exception yourself.</p> <p>Unfortunately, there is no magic involved. You cannot just put an instruction somewhere and have transactions done automatically: you still have to specific which group of queries must be executed in a transaction.</p> <p>For example, quite often you'll have a couple of queries before the transaction (before the begin) and another couple of queries after the transaction (after either commit or rollback) and you'll want those queries executed no matter what happened (or not) in the transaction.</p> <p>ANOTHER HELPFUL LINK: <a href="https://stackoverflow.com/questions/10155946/php-pdo-transactions">PHP PDO Transactions?</a></p> </div>

Symfony获取未标记为已删除的嵌套实体

<div class="post-text" itemprop="text"> <p>I am programming my first symfony project and I stuck at a problem: I have a entity I called it "load" which refers to other entities which a call "transaction" (x transactions belongs to 1 load) :</p> <pre><code> /** * @ORM\OneToMany(targetEntity="Transaction", mappedBy="load") * */ private $transactions; </code></pre> <p>The transactions can be flagged as deleted but they keep stored in the database. I created a custom repository and some methods which deliver me the undeleted transactions.</p> <p>But if I want to fetch a load with all it's transactions, I call</p> <pre><code> $load = $loadRepository-&gt;find($id); </code></pre> <p>it does what it is supposed. It fetches all transactions from the database which are referenced to the given load. </p> <p>But I don't want to have the deleted transactions in my result. How can I achive this? I have absolutely no approach. Sure, I can iterate over the transactions and remove the deleted ones but I think there is a better solution. </p> <p>I tried to register a repository for the transactions (this works) and override the find-method (this doesn't work). Is there another method which is internally called and I have to override?</p> <p>thank you in advance!</p> </div>

学Python后到底能干什么?网友:我太难了

感觉全世界营销文都在推Python,但是找不到工作的话,又有哪个机构会站出来给我推荐工作? 笔者冷静分析多方数据,想跟大家说:关于超越老牌霸主Java,过去几年间Python一直都被寄予厚望。但是事实是虽然上升趋势,但是国内环境下,一时间是无法马上就超越Java的,也可以换句话说:超越Java只是时间问题罢。 太嚣张了会Python的人!找工作拿高薪这么简单? https://edu....

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

为什么程序猿都不愿意去外包?

分享外包的组织架构,盈利模式,亲身经历,以及根据一些外包朋友的反馈,写了这篇文章 ,希望对正在找工作的老铁有所帮助

Java校招入职华为,半年后我跑路了

何来 我,一个双非本科弟弟,有幸在 19 届的秋招中得到前东家华为(以下简称 hw)的赏识,当时秋招签订就业协议,说是入了某 java bg,之后一系列组织架构调整原因等等让人无法理解的神操作,最终毕业前夕,被通知调往其他 bg 做嵌入式开发(纯 C 语言)。 由于已至于校招末尾,之前拿到的其他 offer 又无法再收回,一时感到无力回天,只得默默接受。 毕业后,直接入职开始了嵌入式苦旅,由于从未...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

@程序员:GitHub这个项目快薅羊毛

今天下午在朋友圈看到很多人都在发github的羊毛,一时没明白是怎么回事。 后来上百度搜索了一下,原来真有这回事,毕竟资源主义的羊毛不少啊,1000刀刷爆了朋友圈!不知道你们的朋友圈有没有看到类似的消息。 这到底是啥情况? 微软开发者平台GitHub 的一个区块链项目 Handshake ,搞了一个招募新会员的活动,面向GitHub 上前 25万名开发者派送 4,246.99 HNS币,大约价...

用python打开电脑摄像头,并把图像传回qq邮箱【Pyinstaller打包】

前言: 如何悄悄的打开朋友的摄像头,看看她最近过的怎么样,嘿嘿!这次让我带你们来实现这个功能。 注: 这个程序仅限在朋友之间开玩笑,别去搞什么违法的事情哦。 代码 发送邮件 使用python内置的email模块即可完成。导入相应的代码封装为一个send函数,顺便导入需要导入的包 注: 下面的代码有三处要修改的地方,两处写的qq邮箱地址,还有一处写的qq邮箱授权码,不知道qq邮箱授权码的可以去百度一...

做了5年运维,靠着这份监控知识体系,我从3K变成了40K

从来没讲过运维,因为我觉得运维这种东西不需要太多的知识面,然后我一个做了运维朋友告诉我大错特错,他就是从3K的运维一步步到40K的,甚至笑着说:我现在感觉自己什么都能做。 既然讲,就讲最重要的吧。 监控是整个运维乃至整个产品生命周期中最重要的一环,事前及时预警发现故障,事后提供详实的数据用于追查定位问题。目前业界有很多不错的开源产品可供选择。选择一款开源的监控系统,是一个省时省力、效率最高的方...

C++(继承):19---虚基类与虚继承(virtual)

一、菱形继承 在介绍虚继承之前介绍一下菱形继承 概念:A作为基类,B和C都继承与A。最后一个类D又继承于B和C,这样形式的继承称为菱形继承 菱形继承的缺点: 数据冗余:在D中会保存两份A的内容 访问不明确(二义性):因为D不知道是以B为中介去访问A还是以C为中介去访问A,因此在访问某些成员的时候会发生二义性 缺点的解决: 数据冗余:通过下面“虚继承”技术来解决(见下) 访问...

再不跳槽,应届毕业生拿的都比我多了!

跳槽几乎是每个人职业生涯的一部分,很多HR说“三年两跳”已经是一个跳槽频繁与否的阈值了,可为什么市面上有很多程序员不到一年就跳槽呢?他们不担心影响履历吗? PayScale之前发布的**《员工最短任期公司排行榜》中,两家码农大厂Amazon和Google**,以1年和1.1年的员工任期中位数分列第二、第四名。 PayScale:员工最短任期公司排行榜 意外的是,任期中位数极小的这两家公司,薪资...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

华为初面+综合面试(Java技术面)附上面试题

华为面试整体流程大致分为笔试,性格测试,面试,综合面试,回学校等结果。笔试来说,华为的难度较中等,选择题难度和网易腾讯差不多。最后的代码题,相比下来就简单很多,一共3道题目,前2题很容易就AC,题目已经记不太清楚,不过难度确实不大。最后一题最后提交的代码过了75%的样例,一直没有发现剩下的25%可能存在什么坑。 笔试部分太久远,我就不怎么回忆了。直接将面试。 面试 如果说腾讯的面试是挥金如土...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

win10暴力查看wifi密码

刚才邻居打了个电话说:喂小灰,你家wifi的密码是多少,我怎么连不上了。 我。。。 我也忘了哎,就找到了一个好办法,分享给大家: 第一种情况:已经连接上的wifi,怎么知道密码? 打开:控制面板\网络和 Internet\网络连接 然后右击wifi连接的无线网卡,选择状态 然后像下图一样: 第二种情况:前提是我不知道啊,但是我以前知道密码。 此时可以利用dos命令了 1、利用netsh wlan...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

女朋友过生日,我花了20分钟给她写了一个代理服务器

女朋友说:“看你最近挺辛苦的,我送你一个礼物吧。你看看想要什么,我来准备。” 我想了半天,从书到鞋子到电子产品最后到生活用品,感觉自己什么都不缺,然后和她说:“你省省钱吧,我什么都不需要。” 她坚持要送:“不行,你一定要说一个礼物,我想送你东西了。” 于是,我认真了起来,拿起手机,上淘宝逛了几分钟,但还是没能想出来缺点什么,最后实在没办法了:“这样吧,如果你实在想送东西,那你就写一个代理服务器吧”...

记一次腾讯面试,我挂在了最熟悉不过的队列上……

腾讯后台面试,面试官问:如何自己实现队列?

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

!大部分程序员只会写3年代码

如果世界上都是这种不思进取的软件公司,那别说大部分程序员只会写 3 年代码,恐怕就没有程序员这种职业。

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

立即提问
相关内容推荐