Passed
Push — master ( 8673f8...5c56ce )
by Aimeos
04:42
created

Standard::fetch()   B

Complexity

Conditions 7
Paths 30

Size

Total Lines 31
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

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