Passed
Push — master ( 0115e8...3bf164 )
by Aimeos
04:55
created

Standard::getSearchAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2024
6
 * @package MShop
7
 * @subpackage Coupon
8
 */
9
10
11
namespace Aimeos\MShop\Coupon\Manager\Code;
12
13
14
/**
15
 * Default coupon manager interface for creating and handling coupons.
16
 *
17
 * @package MShop
18
 * @subpackage Coupon
19
 */
20
class Standard
21
	extends \Aimeos\MShop\Common\Manager\Base
22
	implements \Aimeos\MShop\Coupon\Manager\Code\Iface, \Aimeos\MShop\Common\Manager\Factory\Iface
23
{
24
	private array $searchConfig = [
25
		'coupon.code.parentid' => [
26
			'label' => 'Coupon ID',
27
			'internalcode' => 'parentid',
28
			'type' => 'int',
29
			'public' => false,
30
		],
31
		'coupon.code.code' => [
32
			'label' => 'Code value',
33
			'internalcode' => 'code',
34
		],
35
		'coupon.code.count' => [
36
			'label' => 'Code quantity',
37
			'internalcode' => 'count',
38
		],
39
		'coupon.code.datestart' => [
40
			'label' => 'Code start date/time',
41
			'internalcode' => 'start',
42
			'type' => 'datetime',
43
		],
44
		'coupon.code.dateend' => [
45
			'label' => 'Code end date/time',
46
			'internalcode' => 'end',
47
			'type' => 'datetime',
48
		],
49
		'coupon.code.ref' => [
50
			'label' => 'Code reference',
51
			'internalcode' => 'ref',
52
		],
53
	];
54
55
56
	/**
57
	 * Creates a new empty item instance
58
	 *
59
	 * @param array $values Values the item should be initialized with
60
	 * @return \Aimeos\MShop\Coupon\Item\Code\Iface New coupon code item object
61
	 */
62
	public function create( array $values = [] ) : \Aimeos\MShop\Common\Item\Iface
63
	{
64
		$values['.date'] = $this->context()->datetime();
65
		$values['coupon.code.siteid'] = $values['coupon.code.siteid'] ?? $this->context()->locale()->getSiteId();
66
67
		return new \Aimeos\MShop\Coupon\Item\Code\Standard( 'coupon.code.', $values );
68
	}
69
70
71
	/**
72
	 * Decreases the counter of the coupon code.
73
	 *
74
	 * @param string $code Unique code of a coupon
75
	 * @param int $amount Amount the coupon count should be decreased
76
	 * @return \Aimeos\MShop\Coupon\Manager\Code\Iface Manager object for chaining method calls
77
	 */
78
	public function decrease( string $code, int $amount ) : \Aimeos\MShop\Coupon\Manager\Code\Iface
79
	{
80
		return $this->increase( $code, -$amount );
81
	}
82
83
84
	/**
85
	 * Creates a filter object.
86
	 *
87
	 * @param bool|null $default Add default criteria or NULL for relaxed default criteria
88
	 * @param bool $site TRUE for adding site criteria to limit items by the site of related items
89
	 * @return \Aimeos\Base\Criteria\Iface Returns the filter object
90
	 */
91
	public function filter( ?bool $default = false, bool $site = false ) : \Aimeos\Base\Criteria\Iface
92
	{
93
		$object = parent::filter();
94
95
		if( $default )
96
		{
97
			$date = $this->context()->datetime();
98
			$expr = [
99
				$object->or( [
100
					$object->compare( '==', 'coupon.code.count', null ),
101
					$object->compare( '>', 'coupon.code.count', 0 ),
102
				] ),
103
				$object->or( [
104
					$object->compare( '==', 'coupon.code.datestart', null ),
105
					$object->compare( '<=', 'coupon.code.datestart', $date ),
106
				] ),
107
				$object->or( [
108
					$object->compare( '==', 'coupon.code.dateend', null ),
109
					$object->compare( '>=', 'coupon.code.dateend', $date ),
110
				] ),
111
			];
112
113
			$object->add( $object->and( $expr ) );
114
		}
115
116
		return $object;
117
	}
118
119
120
	/**
121
	 * Returns the item specified by its code and domain/type if necessary
122
	 *
123
	 * @param string $code Code of the item
124
	 * @param string[] $ref List of domains to fetch list items and referenced items for
125
	 * @param string|null $domain Domain of the item if necessary to identify the item uniquely
126
	 * @param string|null $type Type code of the item if necessary to identify the item uniquely
127
	 * @param bool|null $default Add default criteria or NULL for relaxed default criteria
128
	 * @return \Aimeos\MShop\Common\Item\Iface Item object
129
	 */
130
	public function find( string $code, array $ref = [], string $domain = null, string $type = null,
131
		?bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
132
	{
133
		return $this->findBase( ['coupon.code.code' => $code], $ref, $default );
134
	}
135
136
137
	/**
138
	 * Returns the additional column/search definitions
139
	 *
140
	 * @return array Associative list of column names as keys and items implementing \Aimeos\Base\Criteria\Attribute\Iface
141
	 */
142
	public function getSaveAttributes() : array
143
	{
144
		return $this->createAttributes( $this->searchConfig );
145
	}
146
147
148
	/**
149
	 * Returns the attributes that can be used for searching.
150
	 *
151
	 * @param bool $withsub Return also attributes of sub-managers if true
152
	 * @return \Aimeos\Base\Criteria\Attribute\Iface[] List of search attribute items
153
	 */
154
	public function getSearchAttributes( bool $withsub = true ) : array
155
	{
156
		return array_replace( parent::getSearchAttributes( $withsub ), $this->createAttributes( [
157
			'coupon.code.id' => [
158
				'label' => 'Code ID',
159
				'internaldeps' => ['LEFT JOIN "mshop_coupon_code" AS mcouco ON (mcou."id"=mcouco."parentid")'],
160
				'internalcode' => 'id',
161
				'type' => 'int',
162
				'public' => false,
163
			]
164
		] ) );
165
	}
166
167
168
	/**
169
	 * Increases the counter of the coupon code.
170
	 *
171
	 * @param string $code Unique code of a coupon
172
	 * @param int $amount Amount the coupon count should be increased
173
	 * @return \Aimeos\MShop\Coupon\Manager\Code\Iface Manager object for chaining method calls
174
	 */
175
	public function increase( string $code, int $amount ) : \Aimeos\MShop\Coupon\Manager\Code\Iface
176
	{
177
		$context = $this->context();
178
		$level = \Aimeos\MShop\Locale\Manager\Base::SITE_PATH;
179
180
		$search = $this->object()->filter();
181
		$search->setConditions( $search->compare( '==', 'coupon.code.siteid', $context->locale()->getSites( $level ) ) );
182
183
		$translations = ['coupon.code.siteid' => 'siteid'];
184
		$types = ['coupon.code.siteid' => \Aimeos\Base\Criteria\SQL::type( 'string' )];
185
		$conditions = $search->getConditionSource( $types, $translations );
186
187
		$conn = $context->db( $this->getResourceName() );
188
189
		/** mshop/coupon/manager/code/counter/mysql
190
		 * Increases or decreases the counter of the coupon code record matched by the given code
191
		 *
192
		 * @see mshop/coupon/manager/code/counter/ansi
193
		 */
194
195
		/** mshop/coupon/manager/code/counter/ansi
196
		 * Increases or decreases the counter of the coupon code record matched by the given code
197
		 *
198
		 * A counter is associated to each coupon code and it's decreased
199
		 * each time by one if a code used in an paid order was redeemed
200
		 * successfully. Shop owners can also use the coupon code counter to
201
		 * use the same code more often by setting it to an arbitrary value.
202
		 * In this case, the code can be redeemed until the counter reaches
203
		 * zero.
204
		 *
205
		 * The coupon codes must be from one of the sites that are configured
206
		 * via the context item. If the current site is part of a tree of
207
		 * sites, the statement can increase or decrease codes from the
208
		 * current site and all parent sites if the code is inherited by one
209
		 * of the parent sites.
210
		 *
211
		 * Each time the code is updated, the modify date/time is set to
212
		 * the current timestamp and the editor field is updated.
213
		 *
214
		 * @param string SQL statement for increasing/decreasing the coupon code count
215
		 * @since 2015.10
216
		 * @see mshop/coupon/manager/code/insert/ansi
217
		 * @see mshop/coupon/manager/code/update/ansi
218
		 * @see mshop/coupon/manager/code/newid/ansi
219
		 * @see mshop/coupon/manager/code/delete/ansi
220
		 * @see mshop/coupon/manager/code/search/ansi
221
		 * @see mshop/coupon/manager/code/count/ansi
222
		 */
223
		$path = 'mshop/coupon/manager/code/counter';
224
		$stmt = $conn->create( str_replace( ':cond', $conditions, $this->getSqlConfig( $path ) ) );
225
226
		$stmt->bind( 1, $amount, \Aimeos\Base\DB\Statement\Base::PARAM_INT );
227
		$stmt->bind( 2, $context->datetime() ); // mtime
228
		$stmt->bind( 3, $context->editor() );
229
		$stmt->bind( 4, $code );
230
231
		$stmt->execute()->finish();
232
233
		return $this;
234
	}
235
236
237
	/**
238
	 * Returns the prefix for the item properties and search keys.
239
	 *
240
	 * @return string Prefix for the item properties and search keys
241
	 */
242
	protected function prefix() : string
243
	{
244
		return 'coupon.code.';
245
	}
246
247
248
	/** mshop/coupon/manager/code/name
249
	 * Class name of the used coupon code manager implementation
250
	 *
251
	 * Each default coupon code manager can be replaced by an alternative imlementation.
252
	 * To use this implementation, you have to set the last part of the class
253
	 * name as configuration value so the manager factory knows which class it
254
	 * has to instantiate.
255
	 *
256
	 * For example, if the name of the default class is
257
	 *
258
	 *  \Aimeos\MShop\Coupon\Manager\Address\Standard
259
	 *
260
	 * and you want to replace it with your own version named
261
	 *
262
	 *  \Aimeos\MShop\Coupon\Manager\Address\Mycode
263
	 *
264
	 * then you have to set the this configuration option:
265
	 *
266
	 *  mshop/coupon/manager/code/name = Mycode
267
	 *
268
	 * The value is the last part of your own class name and it's case sensitive,
269
	 * so take care that the configuration value is exactly named like the last
270
	 * part of the class name.
271
	 *
272
	 * The allowed characters of the class name are A-Z, a-z and 0-9. No other
273
	 * characters are possible! You should always start the last part of the class
274
	 * name with an upper case character and continue only with lower case characters
275
	 * or numbers. Avoid chamel case names like "MyAddress"!
276
	 *
277
	 * @param string Last part of the class name
278
	 * @since 2015.10
279
	 */
280
281
	/** mshop/coupon/manager/code/decorators/excludes
282
	 * Excludes decorators added by the "common" option from the coupon code manager
283
	 *
284
	 * Decorators extend the functionality of a class by adding new aspects
285
	 * (e.g. log what is currently done), executing the methods of the underlying
286
	 * class only in certain conditions (e.g. only for logged in users) or
287
	 * modify what is returned to the caller.
288
	 *
289
	 * This option allows you to remove a decorator added via
290
	 * "mshop/common/manager/decorators/default" before they are wrapped
291
	 * around the coupon code manager.
292
	 *
293
	 *  mshop/coupon/manager/code/decorators/excludes = array( 'decorator1' )
294
	 *
295
	 * This would remove the decorator named "decorator1" from the list of
296
	 * common decorators ("\Aimeos\MShop\Common\Manager\Decorator\*") added via
297
	 * "mshop/common/manager/decorators/default" for the coupon code manager.
298
	 *
299
	 * @param array Address of decorator names
300
	 * @since 2015.10
301
	 * @see mshop/common/manager/decorators/default
302
	 * @see mshop/coupon/manager/code/decorators/global
303
	 * @see mshop/coupon/manager/code/decorators/local
304
	 */
305
306
	/** mshop/coupon/manager/code/decorators/global
307
	 * Adds a list of globally available decorators only to the coupon code manager
308
	 *
309
	 * Decorators extend the functionality of a class by adding new aspects
310
	 * (e.g. log what is currently done), executing the methods of the underlying
311
	 * class only in certain conditions (e.g. only for logged in users) or
312
	 * modify what is returned to the caller.
313
	 *
314
	 * This option allows you to wrap global decorators
315
	 * ("\Aimeos\MShop\Common\Manager\Decorator\*") around the coupon code manager.
316
	 *
317
	 *  mshop/coupon/manager/code/decorators/global = array( 'decorator1' )
318
	 *
319
	 * This would add the decorator named "decorator1" defined by
320
	 * "\Aimeos\MShop\Common\Manager\Decorator\Decorator1" only to the coupon
321
	 * code manager.
322
	 *
323
	 * @param array Address of decorator names
324
	 * @since 2015.10
325
	 * @see mshop/common/manager/decorators/default
326
	 * @see mshop/coupon/manager/code/decorators/excludes
327
	 * @see mshop/coupon/manager/code/decorators/local
328
	 */
329
330
	/** mshop/coupon/manager/code/decorators/local
331
	 * Adds a list of local decorators only to the coupon code manager
332
	 *
333
	 * Decorators extend the functionality of a class by adding new aspects
334
	 * (e.g. log what is currently done), executing the methods of the underlying
335
	 * class only in certain conditions (e.g. only for logged in users) or
336
	 * modify what is returned to the caller.
337
	 *
338
	 * This option allows you to wrap local decorators
339
	 * ("\Aimeos\MShop\Coupon\Manager\Code\Decorator\*") around the coupon code
340
	 * manager.
341
	 *
342
	 *  mshop/coupon/manager/code/decorators/local = array( 'decorator2' )
343
	 *
344
	 * This would add the decorator named "decorator2" defined by
345
	 * "\Aimeos\MShop\Coupon\Manager\Code\Decorator\Decorator2" only to the
346
	 * coupon code manager.
347
	 *
348
	 * @param array Address of decorator names
349
	 * @since 2015.10
350
	 * @see mshop/common/manager/decorators/default
351
	 * @see mshop/coupon/manager/code/decorators/excludes
352
	 * @see mshop/coupon/manager/code/decorators/global
353
	 */
354
355
	/** mshop/coupon/manager/code/submanagers
356
	 * List of manager names that can be instantiated by the coupon code manager
357
	 *
358
	 * Managers provide a generic interface to the underlying storage.
359
	 * Each manager has or can have sub-managers caring about particular
360
	 * aspects. Each of these sub-managers can be instantiated by its
361
	 * parent manager using the getSubManager() method.
362
	 *
363
	 * The search keys from sub-managers can be normally used in the
364
	 * manager as well. It allows you to search for items of the manager
365
	 * using the search keys of the sub-managers to further limit the
366
	 * retrieved list of items.
367
	 *
368
	 * @param array List of sub-manager names
369
	 * @since 2015.10
370
	 */
371
372
	/** mshop/coupon/manager/code/insert/mysql
373
	 * Inserts a new coupon code record into the database table
374
	 *
375
	 * @see mshop/coupon/manager/code/insert/ansi
376
	 */
377
378
	/** mshop/coupon/manager/code/insert/ansi
379
	 * Inserts a new coupon code record into the database table
380
	 *
381
	 * Items with no ID yet (i.e. the ID is NULL) will be created in
382
	 * the database and the newly created ID retrieved afterwards
383
	 * using the "newid" SQL statement.
384
	 *
385
	 * The SQL statement must be a string suitable for being used as
386
	 * prepared statement. It must include question marks for binding
387
	 * the values from the coupon item to the statement before they are
388
	 * sent to the database server. The number of question marks must
389
	 * be the same as the number of columns listed in the INSERT
390
	 * statement. The order of the columns must correspond to the
391
	 * order in the save() method, so the correct values are
392
	 * bound to the columns.
393
	 *
394
	 * The SQL statement should conform to the ANSI standard to be
395
	 * compatible with most relational database systems. This also
396
	 * includes using double quotes for table and column names.
397
	 *
398
	 * @param string SQL statement for inserting records
399
	 * @since 2015.10
400
	 * @see mshop/coupon/manager/code/update/ansi
401
	 * @see mshop/coupon/manager/code/newid/ansi
402
	 * @see mshop/coupon/manager/code/delete/ansi
403
	 * @see mshop/coupon/manager/code/search/ansi
404
	 * @see mshop/coupon/manager/code/count/ansi
405
	 * @see mshop/coupon/manager/code/counter/ansi
406
	 */
407
408
	/** mshop/coupon/manager/code/update/mysql
409
	 * Updates an existing coupon code record in the database
410
	 *
411
	 * @see mshop/coupon/manager/code/update/ansi
412
	 */
413
414
	/** mshop/coupon/manager/code/update/ansi
415
	 * Updates an existing coupon code record in the database
416
	 *
417
	 * Items which already have an ID (i.e. the ID is not NULL) will
418
	 * be updated in the database.
419
	 *
420
	 * The SQL statement must be a string suitable for being used as
421
	 * prepared statement. It must include question marks for binding
422
	 * the values from the coupon item to the statement before they are
423
	 * sent to the database server. The order of the columns must
424
	 * correspond to the order in the save() method, so the
425
	 * correct values are bound to the columns.
426
	 *
427
	 * The SQL statement should conform to the ANSI standard to be
428
	 * compatible with most relational database systems. This also
429
	 * includes using double quotes for table and column names.
430
	 *
431
	 * @param string SQL statement for updating records
432
	 * @since 2015.10
433
	 * @see mshop/coupon/manager/code/insert/ansi
434
	 * @see mshop/coupon/manager/code/newid/ansi
435
	 * @see mshop/coupon/manager/code/delete/ansi
436
	 * @see mshop/coupon/manager/code/search/ansi
437
	 * @see mshop/coupon/manager/code/count/ansi
438
	 * @see mshop/coupon/manager/code/counter/ansi
439
	 */
440
441
	/** mshop/coupon/manager/code/newid/mysql
442
	 * Retrieves the ID generated by the database when inserting a new record
443
	 *
444
	 * @see mshop/coupon/manager/code/newid/ansi
445
	 */
446
447
	/** mshop/coupon/manager/code/newid/ansi
448
	 * Retrieves the ID generated by the database when inserting a new record
449
	 *
450
	 * As soon as a new record is inserted into the database table,
451
	 * the database server generates a new and unique identifier for
452
	 * that record. This ID can be used for retrieving, updating and
453
	 * deleting that specific record from the table again.
454
	 *
455
	 * For MySQL:
456
	 *  SELECT LAST_INSERT_ID()
457
	 * For PostgreSQL:
458
	 *  SELECT currval('seq_mcouco_id')
459
	 * For SQL Server:
460
	 *  SELECT SCOPE_IDENTITY()
461
	 * For Oracle:
462
	 *  SELECT "seq_mcouco_id".CURRVAL FROM DUAL
463
	 *
464
	 * There's no way to retrive the new ID by a SQL statements that
465
	 * fits for most database servers as they implement their own
466
	 * specific way.
467
	 *
468
	 * @param string SQL statement for retrieving the last inserted record ID
469
	 * @since 2015.10
470
	 * @see mshop/coupon/manager/code/insert/ansi
471
	 * @see mshop/coupon/manager/code/update/ansi
472
	 * @see mshop/coupon/manager/code/delete/ansi
473
	 * @see mshop/coupon/manager/code/search/ansi
474
	 * @see mshop/coupon/manager/code/count/ansi
475
	 * @see mshop/coupon/manager/code/counter/ansi
476
	 */
477
478
	/** mshop/coupon/manager/code/delete/mysql
479
	 * Deletes the items matched by the given IDs from the database
480
	 *
481
	 * @see mshop/coupon/manager/code/delete/ansi
482
	 */
483
484
	/** mshop/coupon/manager/code/delete/ansi
485
	 * Deletes the items matched by the given IDs from the database
486
	 *
487
	 * Removes the records specified by the given IDs from the coupon database.
488
	 * The records must be from the site that is configured via the
489
	 * context item.
490
	 *
491
	 * The ":cond" placeholder is replaced by the name of the ID column and
492
	 * the given ID or list of IDs while the site ID is bound to the question
493
	 * mark.
494
	 *
495
	 * The SQL statement should conform to the ANSI standard to be
496
	 * compatible with most relational database systems. This also
497
	 * includes using double quotes for table and column names.
498
	 *
499
	 * @param string SQL statement for deleting items
500
	 * @since 2015.10
501
	 * @see mshop/coupon/manager/code/insert/ansi
502
	 * @see mshop/coupon/manager/code/update/ansi
503
	 * @see mshop/coupon/manager/code/newid/ansi
504
	 * @see mshop/coupon/manager/code/search/ansi
505
	 * @see mshop/coupon/manager/code/count/ansi
506
	 * @see mshop/coupon/manager/code/counter/ansi
507
	 */
508
509
	/** mshop/coupon/manager/code/search/mysql
510
	 * Retrieves the records matched by the given criteria in the database
511
	 *
512
	 * @see mshop/coupon/manager/code/search/ansi
513
	 */
514
515
	/** mshop/coupon/manager/code/search/ansi
516
	 * Retrieves the records matched by the given criteria in the database
517
	 *
518
	 * Fetches the records matched by the given criteria from the coupon
519
	 * database. The records must be from one of the sites that are
520
	 * configured via the context item. If the current site is part of
521
	 * a tree of sites, the SELECT statement can retrieve all records
522
	 * from the current site and the complete sub-tree of sites.
523
	 *
524
	 * As the records can normally be limited by criteria from sub-managers,
525
	 * their tables must be joined in the SQL context. This is done by
526
	 * using the "internaldeps" property from the definition of the ID
527
	 * column of the sub-managers. These internal dependencies specify
528
	 * the JOIN between the tables and the used columns for joining. The
529
	 * ":joins" placeholder is then replaced by the JOIN strings from
530
	 * the sub-managers.
531
	 *
532
	 * To limit the records matched, conditions can be added to the given
533
	 * criteria object. It can contain comparisons like column names that
534
	 * must match specific values which can be combined by AND, OR or NOT
535
	 * operators. The resulting string of SQL conditions replaces the
536
	 * ":cond" placeholder before the statement is sent to the database
537
	 * server.
538
	 *
539
	 * If the records that are retrieved should be ordered by one or more
540
	 * columns, the generated string of column / sort direction pairs
541
	 * replaces the ":order" placeholder. Columns of
542
	 * sub-managers can also be used for ordering the result set but then
543
	 * no index can be used.
544
	 *
545
	 * The number of returned records can be limited and can start at any
546
	 * number between the begining and the end of the result set. For that
547
	 * the ":size" and ":start" placeholders are replaced by the
548
	 * corresponding values from the criteria object. The default values
549
	 * are 0 for the start and 100 for the size value.
550
	 *
551
	 * The SQL statement should conform to the ANSI standard to be
552
	 * compatible with most relational database systems. This also
553
	 * includes using double quotes for table and column names.
554
	 *
555
	 * @param string SQL statement for searching items
556
	 * @since 2015.10
557
	 * @see mshop/coupon/manager/code/insert/ansi
558
	 * @see mshop/coupon/manager/code/update/ansi
559
	 * @see mshop/coupon/manager/code/newid/ansi
560
	 * @see mshop/coupon/manager/code/delete/ansi
561
	 * @see mshop/coupon/manager/code/count/ansi
562
	 * @see mshop/coupon/manager/code/counter/ansi
563
	 */
564
565
	/** mshop/coupon/manager/code/count/mysql
566
	 * Counts the number of records matched by the given criteria in the database
567
	 *
568
	 * @see mshop/coupon/manager/code/count/ansi
569
	 */
570
571
	/** mshop/coupon/manager/code/count/ansi
572
	 * Counts the number of records matched by the given criteria in the database
573
	 *
574
	 * Counts all records matched by the given criteria from the coupon
575
	 * database. The records must be from one of the sites that are
576
	 * configured via the context item. If the current site is part of
577
	 * a tree of sites, the statement can count all records from the
578
	 * current site and the complete sub-tree of sites.
579
	 *
580
	 * As the records can normally be limited by criteria from sub-managers,
581
	 * their tables must be joined in the SQL context. This is done by
582
	 * using the "internaldeps" property from the definition of the ID
583
	 * column of the sub-managers. These internal dependencies specify
584
	 * the JOIN between the tables and the used columns for joining. The
585
	 * ":joins" placeholder is then replaced by the JOIN strings from
586
	 * the sub-managers.
587
	 *
588
	 * To limit the records matched, conditions can be added to the given
589
	 * criteria object. It can contain comparisons like column names that
590
	 * must match specific values which can be combined by AND, OR or NOT
591
	 * operators. The resulting string of SQL conditions replaces the
592
	 * ":cond" placeholder before the statement is sent to the database
593
	 * server.
594
	 *
595
	 * Both, the strings for ":joins" and for ":cond" are the same as for
596
	 * the "search" SQL statement.
597
	 *
598
	 * Contrary to the "search" statement, it doesn't return any records
599
	 * but instead the number of records that have been found. As counting
600
	 * thousands of records can be a long running task, the maximum number
601
	 * of counted records is limited for performance reasons.
602
	 *
603
	 * The SQL statement should conform to the ANSI standard to be
604
	 * compatible with most relational database systems. This also
605
	 * includes using double quotes for table and column names.
606
	 *
607
	 * @param string SQL statement for counting items
608
	 * @since 2015.10
609
	 * @see mshop/coupon/manager/code/insert/ansi
610
	 * @see mshop/coupon/manager/code/update/ansi
611
	 * @see mshop/coupon/manager/code/newid/ansi
612
	 * @see mshop/coupon/manager/code/delete/ansi
613
	 * @see mshop/coupon/manager/code/search/ansi
614
	 * @see mshop/coupon/manager/code/counter/ansi
615
	 */
616
}
617