mysql

what is the best solutions to mysql connection timeout?

独自空忆成欢 提交于 2021-02-19 07:32:27
问题 I am writing a small web app in Go, which uses mysql to store data. I got intermittent mysql error if the web sever didn't get any request after some amount of time(> 8 hours): [mysql] 2017/02/08 16:31:56 packets.go:33: unexpected EOF [mysql] 2017/02/08 16:31:56 packets.go:130: write tcp 127.0.0.1:49188->127.0.0.1:3306: write: broken pipe I found some related discussion on github(issue 529, issue 257 and issue 446). From what I understand, mysql db would close the connection if timeout is

Laravel Eloquent object, longtext being truncated

拜拜、爱过 提交于 2021-02-19 07:18:25
问题 I've using Laravel, loading a db row into an Eloquent object. One of the columns is longtext, a JSON encoded array > 2 million characters long. The original error I was getting was json_decode failing on this column's value. I tested in tinker. Simplified test code: $item = Item::find(1); echo $item->long_text_field; var_dump(json_decode($item->long_text_field)); echo strlen($item->long_text_field); On my local vagrant instance this shows the correct values. ...long json array in text, same

Laravel Eloquent object, longtext being truncated

做~自己de王妃 提交于 2021-02-19 07:12:58
问题 I've using Laravel, loading a db row into an Eloquent object. One of the columns is longtext, a JSON encoded array > 2 million characters long. The original error I was getting was json_decode failing on this column's value. I tested in tinker. Simplified test code: $item = Item::find(1); echo $item->long_text_field; var_dump(json_decode($item->long_text_field)); echo strlen($item->long_text_field); On my local vagrant instance this shows the correct values. ...long json array in text, same

Laravel Eloquent object, longtext being truncated

主宰稳场 提交于 2021-02-19 07:12:39
问题 I've using Laravel, loading a db row into an Eloquent object. One of the columns is longtext, a JSON encoded array > 2 million characters long. The original error I was getting was json_decode failing on this column's value. I tested in tinker. Simplified test code: $item = Item::find(1); echo $item->long_text_field; var_dump(json_decode($item->long_text_field)); echo strlen($item->long_text_field); On my local vagrant instance this shows the correct values. ...long json array in text, same

Can i adjust the value of an auto-incremented field in the database automatically?

走远了吗. 提交于 2021-02-19 06:31:33
问题 Can i adjust the value of an auto-incremented field in the database automatically? I have a table called "post" which has a field called "pid" which is set to auto-increment. Posts from this table may be deleted by the user at a later time, but the auto- incremented value will not be adjusted. Is there a way to adjust the pid field everytime posts are deleted? for eg:If i have 4 entries: pid=1,2,3,4(pid-auto-increment) Now if i delete 2, is there a way to update 3 to 2 and 4 to 3 and so on ?

Can i adjust the value of an auto-incremented field in the database automatically?

柔情痞子 提交于 2021-02-19 06:31:14
问题 Can i adjust the value of an auto-incremented field in the database automatically? I have a table called "post" which has a field called "pid" which is set to auto-increment. Posts from this table may be deleted by the user at a later time, but the auto- incremented value will not be adjusted. Is there a way to adjust the pid field everytime posts are deleted? for eg:If i have 4 entries: pid=1,2,3,4(pid-auto-increment) Now if i delete 2, is there a way to update 3 to 2 and 4 to 3 and so on ?

Adding to row in MySQL if it doesn't exist

☆樱花仙子☆ 提交于 2021-02-19 06:22:10
问题 When adding a row to a table, but first checking to see if it exists first Which would be the most efficient way of handling this? Would it be a case of query to see if it exist, if not then insert. Or using on duplicate? Or simply replace (Would this work, if the row did not exist)? Thanks 回答1: I think this is the fastest way in MySQL: REPLACE into table (col1, col2) values(1, 'ABC') EDIT: MySQL will delete the row if it does exist and insert a new one. 回答2: I think you need INSERT IGNORE

PHP Reverse the order of results from MySQL DB [duplicate]

ぐ巨炮叔叔 提交于 2021-02-19 06:18:05
问题 This question already has answers here : How to reverse order output of MySQL query (6 answers) Closed 10 days ago . I want to reverse the order of the array. My code: $result = mysql_query("SELECT * FROM notfi1 WHERE Own='" .$_GET['u']. "'"); while($row = mysql_fetch_array($result)) { echo 'link:<a href=member.php?u=' .$row['UserId']. '>text</a><br>'; } Output: <a href=member.php?u=name8>text</a> <a href=member.php?u=name9>text</a> <a href=member.php?u=name10>text</a> and I want to reverse

Strongloop: filter data with [and] and [or] conditions together

那年仲夏 提交于 2021-02-19 06:00:35
问题 I'm trying to filter data using "and" and "or" conditions. I would like to get this mySql query: SELECT * FROM `data` WHERE ((`property1`=11) OR (`property1`=13)) AND (`property2`=6) The rest api that I wrote is like this: http://localhost:4000/api/Data/?filter[where][or][0][property1]=11&filter[where][or][1][property1]=13&filter[where][and][0][property2]=6 The loopback json translation seems to be correct: { "or": [ { "property1": 11 }, { "property1": 13 } ], "and": [ { "property2": 6 } ] }

NetSuite Migrations

可紊 提交于 2021-02-19 05:52:14
问题 Has anyone had much experience with data migration into and out of NetSuite? I have to export DB2 tables into MySQL, manipulate data, and then export ina CSV file. Then take a CSV file of accounts and manipulate the data again for accounts to match up from our old system to new. Anyone tried to do this in MySQL? 回答1: A couple of options: Invest in a data transformation tool that connects to NetSuite and DB2 or MySQL. Look at Dell Boomi, IBM Cast Iron, etc. These tools allow you to connect to