Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. $query="SET @laboratory_prefix_id = 5;
  2. SET @min_sample_number = 1;
  3. (
  4. SELECT @count
  5. FROM sample, (select @count := @min_sample_number-1) dummy
  6. WHERE sample.laboratory_prefix_id = @laboratory_prefix_id
  7. AND sample.sample_number > @min_sample_number-1
  8. AND (@count := @count+1) < sample.sample_number
  9. ORDER BY sample.sample_number ASC
  10. LIMIT 1
  11. )
  12. UNION ALL
  13. (
  14. SELECT @min_sample_number
  15. )
  16. ORDER BY 1 DESC
  17. LIMIT 1;";
  18. $rows = Yii::$app->db->createCommand($query)->queryAll();
  19.  
  20. $rows = Yii::$app->db->createCommand('SET @laboratory_prefix_id = 5;')->execute();
  21. $rows = Yii::$app->db->createCommand('SET @min_sample_number = 1;')->execute();
  22. $rows = Yii::$app->db->createCommand($query)->queryAll();
  23.  
  24. (
  25. SELECT @count
  26. FROM sample, (select @laboratory_prefix_id := ?
  27. , @min_sample_number := ?
  28. , @count := @min_sample_number-1) dummy
  29. WHERE sample.laboratory_prefix_id = @laboratory_prefix_id
  30. AND sample.sample_number > @min_sample_number-1
  31. AND (@count := @count+1) < sample.sample_number
  32. ORDER BY sample.sample_number ASC
  33. LIMIT 1
  34. )
  35. UNION ALL
  36. (
  37. SELECT @min_sample_number
  38. )
  39. ORDER BY 1 DESC
  40. LIMIT 1;
  41.  
  42. $rows = Yii::$app->db->createCommand('SET @laboratory_prefix_id = 5;')->execute();
  43. $rows = Yii::$app->db->createCommand('SET @min_sample_number = 1;')->execute();
  44. $rows = Yii::$app->db->createCommand($query)->queryAll();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement