The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
database concurrency
#2
Sure. It would probably be hard to do with any of the existing userspice functions because it would require a lot of modification, but you can definitely do it for all your tables. It would actually be pretty easy. You can't do it technically do it "concurrently" but you can do it in 2 quick steps.

You would do make the last column in your table something like ai (for auto-increment). Let's just say the table is called "data".

So you would load the page normally with something like...

Code:
$dataQ = $db->query("SELECT * FROM data");
Code:
$data = $dataQ->results();

Then you do everything you're going to do.

Then let's say you're going back to update the table, you'll do another final check...

Code:
if(!empty($_POST)){
Code:
$checkQ = $db->query("SELECT * FROM data");
Code:
$check = $checkQ->results();

Code:
if($checkQ->ai != dataQ->ai){
//something changed!
Code:
}else{
//nothing changed
Code:
$fields = array(
Code:
'mydata' => $mydata,
Code:
'ai' => $data->ai+1,
Code:
);
Code:
$db->update('data',1,$fields);
Code:
}
This is for a 1 row database but you could just do this by row if you have many lines.
  Reply


Messages In This Thread
database concurrency - by marceloatmartins - 06-20-2017, 11:36 AM
database concurrency - by mudmin - 06-20-2017, 11:55 AM
database concurrency - by marceloatmartins - 06-20-2017, 12:53 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)