mysql

making a record unique by incrementing a number in javascript

南笙酒味 提交于 2021-02-11 18:09:43
问题 I wanted to increment a number to a filename if the filename already exists in the database (based on the records too). for example if I add file with filename DOC it will check if DOC exist since DOC exist on the example below and the latest increment is 1 (DOC-1) then the filename would be DOC-2. If I add DOC again and the latest increment is 2 so the new filename would be DOC-3.so on and so forth. Any idea guys ? thank you. Sounds like what I want is to always create a new filename (by

MongoDB and MySql Transaction

我怕爱的太早我们不能终老 提交于 2021-02-11 18:09:38
问题 I need to execute a multiple MySql Queries and Multiple MongoDB queries. If the execution of one of the queries fails (SQL or Mongo) I must rollback all the executed queries. Is that possible? 回答1: You might want to check out Spring Transactions. This is one of the solutions I am aware of. Another solution might be to do it manually: store the current documents/rows try to update them and roll back if necessary. It might help to take a step back and ask yourself whether it really makes sense

sql pdo php where in variable

こ雲淡風輕ζ 提交于 2021-02-11 18:08:11
问题 I'd like to select some data from my database using variables. Here is a short version of my code: // $a is either null or something like [1, 2] if ($a) { $debug = implode(',', $a); } else { $debug = [0-9]; } $sql = "SELECT id FROM user WHERE id IN ($debug)" How can I achieve that I get only user 1 and 2 (= value in $a ) if $a is set and all user if $a is not set? 回答1: First : be aware when you directly inject string inside queries, because you can be target of a SQL Injection Second : change

MongoDB and MySql Transaction

霸气de小男生 提交于 2021-02-11 18:04:51
问题 I need to execute a multiple MySql Queries and Multiple MongoDB queries. If the execution of one of the queries fails (SQL or Mongo) I must rollback all the executed queries. Is that possible? 回答1: You might want to check out Spring Transactions. This is one of the solutions I am aware of. Another solution might be to do it manually: store the current documents/rows try to update them and roll back if necessary. It might help to take a step back and ask yourself whether it really makes sense

InnoDB / MySQL - new transaction uses old data on SELECT instead of returning updated data

情到浓时终转凉″ 提交于 2021-02-11 17:57:47
问题 Begin transaction Tx1 Tx1 performs a SELECT Commit Tx1 Begin transaction Tx2 in a different session, using a different connection Tx2 performs a SELECT Update rows in Tx2 Commit Tx2 Begin a new transaction, Tx1 Perform select - get results from step 2(??) Commit Tx1 Begin transaction Tx1 Perform select - get CORRECT results, i.e. the committed updates from Tx2 Very confused... How can this happen? It is happening reliably and consistently. 回答1: Turns out this can happen if the transaction

InnoDB / MySQL - new transaction uses old data on SELECT instead of returning updated data

别来无恙 提交于 2021-02-11 17:57:13
问题 Begin transaction Tx1 Tx1 performs a SELECT Commit Tx1 Begin transaction Tx2 in a different session, using a different connection Tx2 performs a SELECT Update rows in Tx2 Commit Tx2 Begin a new transaction, Tx1 Perform select - get results from step 2(??) Commit Tx1 Begin transaction Tx1 Perform select - get CORRECT results, i.e. the committed updates from Tx2 Very confused... How can this happen? It is happening reliably and consistently. 回答1: Turns out this can happen if the transaction

Is any pros of using BIT(64) instead of UNSIGNED BIGINT in MySQL except representation

て烟熏妆下的殇ゞ 提交于 2021-02-11 17:55:34
问题 I need to have bitmask in database. 64 bit is enough. Most use cases SELECT ... WHERE ... AND mask & value > 0 ... There are exist special datatype: BIT(64) for my case. But MySQL can make bit logical operations with BIGINT too. What I understand at this moment about BIT : Pros: Better visual representation 0b10010000 better 144 (but I can make CONV(144,10,2) with integer and get same representation) Cons: Worse support of type (I had some problem in golang, and wrote own type to work with it

The LINQ expression 'OUTER APPLY Projection Mapping in EF .NET Core 5 Exception

拜拜、爱过 提交于 2021-02-11 17:35:42
问题 After migrating from .NET Core 2.x to .NET Core 5.0, we are facing this problem. Error: (Added as a CODE for better readability) The LINQ expression 'OUTER APPLY Projection Mapping: ( SELECT e0.Id, e0.FirstName, e0.MiddleName, e0.LastName FROM Employees AS e0 WHERE (((e0.Status != 4) && EXISTS ( Projection Mapping: SELECT 1 FROM FunctionRoles AS f0 WHERE t.Id == f0.SchoolId)) && (e0.FunctionRoleId == (Projection Mapping: EmptyProjectionMember -> 0 SELECT TOP(1) f1.Id FROM FunctionRoles AS f1

Distributed Transaction on mysql

扶醉桌前 提交于 2021-02-11 17:31:48
问题 I'm working on a distributed system that uses distributed transactions, which means that I may have a transaction that needs to edit multiple databases (on multiple servers) at the same time. In my system there is a controller to manage the distribution. the scenario that I want to satisfy is: server A wants to initiate a distributed transaction. the participants are server A and server B. so server A sends a request to the controller to initiate a distributed transaction. the controller

Distributed Transaction on mysql

喜夏-厌秋 提交于 2021-02-11 17:30:57
问题 I'm working on a distributed system that uses distributed transactions, which means that I may have a transaction that needs to edit multiple databases (on multiple servers) at the same time. In my system there is a controller to manage the distribution. the scenario that I want to satisfy is: server A wants to initiate a distributed transaction. the participants are server A and server B. so server A sends a request to the controller to initiate a distributed transaction. the controller