@@ -116,6 +116,21 @@ class Statement
116
116
* @var bool
117
117
*/
118
118
private $ _cache ;
119
+
120
+ /**
121
+ * Whether or not the cache should abort when it encounters a warning
122
+ *
123
+ * @var bool
124
+ */
125
+ private $ _failOnWarning = false ;
126
+
127
+ /**
128
+ * Approximate memory limit value (in bytes) that a query can use on the server-side
129
+ * (a value of 0 or less will mean the memory is not limited)
130
+ *
131
+ * @var int
132
+ */
133
+ private $ _memoryLimit = 0 ;
119
134
120
135
/**
121
136
* resultType
@@ -149,6 +164,16 @@ class Statement
149
164
* Bind variables index
150
165
*/
151
166
const ENTRY_BINDVARS = 'bindVars ' ;
167
+
168
+ /**
169
+ * Fail on warning flag
170
+ */
171
+ const ENTRY_FAIL_ON_WARNING = 'failOnWarning ' ;
172
+
173
+ /**
174
+ * Memory limit threshold for query
175
+ */
176
+ const ENTRY_MEMORY_LIMIT = 'memoryLimit ' ;
152
177
153
178
/**
154
179
* Full count option index
@@ -215,6 +240,14 @@ public function __construct(Connection $connection, array $data)
215
240
if (isset ($ data [Cursor::ENTRY_CACHE ])) {
216
241
$ this ->_cache = (bool ) $ data [Cursor::ENTRY_CACHE ];
217
242
}
243
+
244
+ if (isset ($ data [self ::ENTRY_FAIL_ON_WARNING ])) {
245
+ $ this ->_failOnWarning = (bool ) $ data [self ::ENTRY_FAIL_ON_WARNING ];
246
+ }
247
+
248
+ if (isset ($ data [self ::ENTRY_MEMORY_LIMIT ])) {
249
+ $ this ->_memoryLimit = (int ) $ data [self ::ENTRY_MEMORY_LIMIT ];
250
+ }
218
251
}
219
252
220
253
/**
@@ -430,7 +463,7 @@ public function setFullCount($value)
430
463
{
431
464
$ this ->_fullCount = (bool ) $ value ;
432
465
}
433
-
466
+
434
467
/**
435
468
* Get the full count option value of the statement
436
469
*
@@ -462,6 +495,51 @@ public function getCache()
462
495
{
463
496
return $ this ->_cache ;
464
497
}
498
+
499
+ /**
500
+ * Set whether or not the cache should abort when it encounters a warning
501
+ *
502
+ * @param bool $value - value for fail-on-warning
503
+ *
504
+ * @return void
505
+ */
506
+ public function setFailOnWarning ($ value = true )
507
+ {
508
+ $ this ->_failOnWarning = (bool ) $ value ;
509
+ }
510
+
511
+ /**
512
+ * Get the configured value for fail-on-warning
513
+ *
514
+ * @return bool - current value of fail-on-warning option
515
+ */
516
+ public function getFailOnWarning ()
517
+ {
518
+ return $ this ->_failOnWarning ;
519
+ }
520
+
521
+ /**
522
+ * Set the approximate memory limit threshold to be used by the query on the server-side
523
+ * (a value of 0 or less will mean the memory is not limited)
524
+ *
525
+ * @param int $value - value for memory limit
526
+ *
527
+ * @return void
528
+ */
529
+ public function setMemoryLimit ($ value )
530
+ {
531
+ $ this ->_memoryLimit = (int ) $ value ;
532
+ }
533
+
534
+ /**
535
+ * Get the configured memory limit for the statement
536
+ *
537
+ * @return int - current value of memory limit option
538
+ */
539
+ public function getMemoryLimit ()
540
+ {
541
+ return $ this ->_memoryLimit ;
542
+ }
465
543
466
544
/**
467
545
* Set the batch size for the statement
@@ -510,14 +588,19 @@ private function buildData()
510
588
self ::ENTRY_QUERY => $ this ->_query ,
511
589
self ::ENTRY_COUNT => $ this ->_doCount ,
512
590
'options ' => [
513
- self ::FULL_COUNT => $ this ->_fullCount
591
+ self ::FULL_COUNT => $ this ->_fullCount ,
592
+ self ::ENTRY_FAIL_ON_WARNING => $ this ->_failOnWarning
514
593
]
515
594
];
516
595
517
596
if ($ this ->_cache !== null ) {
518
597
$ data [Cursor::ENTRY_CACHE ] = $ this ->_cache ;
519
598
}
520
599
600
+ if ($ this ->_memoryLimit > 0 ) {
601
+ $ data [self ::ENTRY_MEMORY_LIMIT ] = $ this ->_memoryLimit ;
602
+ }
603
+
521
604
if ($ this ->_bindVars ->getCount () > 0 ) {
522
605
$ data [self ::ENTRY_BINDVARS ] = $ this ->_bindVars ->getAll ();
523
606
}
0 commit comments