Passed
Push — master ( 8a4484...3ac2eb )
by Aimeos
04:39
created

Standard::prefix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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
	 * Fetches the rows from the database statement and returns the list of items.
196
	 *
197
	 * @param \Aimeos\Base\DB\Result\Iface $stmt Database statement object
198
	 * @param array $ref List of domains whose items should be fetched too
199
	 * @param string $prefix Prefix for the property names
200
	 * @param array $attrs List of attributes that should be decoded
201
	 * @return \Aimeos\Map List of items implementing \Aimeos\MShop\Common\Item\Iface
202
	 */
203
	protected function fetch( \Aimeos\Base\DB\Result\Iface $results, array $ref, string $prefix = '', array $attrs = [] ) : \Aimeos\Map
204
	{
205
		$map = $items = $parentIds = $propItems = [];
206
207
		while( $row = $results->fetch() )
208
		{
209
			$map[$row['attribute.id']] = $row;
210
			$parentIds[] = $row['attribute.id'];
211
		}
212
213
		if( $this->hasRef( $ref, 'attribute/property' ) )
214
		{
215
			$name = 'attribute/property';
216
			$propTypes = isset( $ref[$name] ) && is_array( $ref[$name] ) ? $ref[$name] : null;
217
218
			$propItems = $this->getPropertyItems( $parentIds, 'attribute', $propTypes );
219
		}
220
221
		$listItems = map( $this->getListItems( $parentIds, $ref, 'attribute' ) )->groupBy( 'attribute.lists.parentid' );
222
223
		foreach( $map as $id => $row )
224
		{
225
			$row['.listitems'] = $listItems[$id] ?? [];
226
			$row['.propitems'] = $propItems[$id] ?? [];
227
228
			if( $item = $this->applyFilter( $this->create( $row ) ) ) {
229
				$items[$id] = $item;
230
			}
231
		}
232
233
		return map( $items );
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 'attribute.';
245
	}
246
247
248
	/**
249
	 * Saves the dependent items of the item
250
	 *
251
	 * @param \Aimeos\MShop\Common\Item\Iface $item Item object
252
	 * @param bool $fetch True if the new ID should be returned in the item
253
	 * @return \Aimeos\MShop\Common\Item\Iface Updated item
254
	 */
255
	protected function saveDeps( \Aimeos\MShop\Common\Item\Iface $item, bool $fetch = true ) : \Aimeos\MShop\Common\Item\Iface
256
	{
257
		$item = $this->savePropertyItems( $item, 'attribute', $fetch );
258
		return $this->saveListItems( $item, 'attribute', $fetch );
0 ignored issues
show
Bug introduced by
$item of type Aimeos\MShop\Common\Item\PropertyRef\Iface is incompatible with the type Aimeos\MShop\Common\Item\ListsRef\Iface expected by parameter $item of Aimeos\MShop\Attribute\M...andard::saveListItems(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

258
		return $this->saveListItems( /** @scrutinizer ignore-type */ $item, 'attribute', $fetch );
Loading history...
259
	}
260
261
262
	/** mshop/attribute/manager/resource
263
	 * Name of the database connection resource to use
264
	 *
265
	 * You can configure a different database connection for each data domain
266
	 * and if no such connection name exists, the "db" connection will be used.
267
	 * It's also possible to use the same database connection for different
268
	 * data domains by configuring the same connection name using this setting.
269
	 *
270
	 * @param string Database connection name
271
	 * @since 2023.04
272
	 */
273
274
	/** mshop/attribute/manager/submanagers
275
	 * List of manager names that can be instantiated by the attribute manager
276
	 *
277
	 * Managers provide a generic interface to the underlying storage.
278
	 * Each manager has or can have sub-managers caring about particular
279
	 * aspects. Each of these sub-managers can be instantiated by its
280
	 * parent manager using the getSubManager() method.
281
	 *
282
	 * The search keys from sub-managers can be normally used in the
283
	 * manager as well. It allows you to search for items of the manager
284
	 * using the search keys of the sub-managers to further limit the
285
	 * retrieved list of items.
286
	 *
287
	 * @param array List of sub-manager names
288
	 * @since 2015.10
289
	 */
290
291
	/** mshop/attribute/manager/name
292
	 * Class name of the used attribute manager implementation
293
	 *
294
	 * Each default manager can be replace by an alternative imlementation.
295
	 * To use this implementation, you have to set the last part of the class
296
	 * name as configuration value so the manager factory knows which class it
297
	 * has to instantiate.
298
	 *
299
	 * For example, if the name of the default class is
300
	 *
301
	 *  \Aimeos\MShop\Attribute\Manager\Standard
302
	 *
303
	 * and you want to replace it with your own version named
304
	 *
305
	 *  \Aimeos\MShop\Attribute\Manager\Mymanager
306
	 *
307
	 * then you have to set the this configuration option:
308
	 *
309
	 *  mshop/attribute/manager/name = Mymanager
310
	 *
311
	 * The value is the last part of your own class name and it's case sensitive,
312
	 * so take care that the configuration value is exactly named like the last
313
	 * part of the class name.
314
	 *
315
	 * The allowed characters of the class name are A-Z, a-z and 0-9. No other
316
	 * characters are possible! You should always start the last part of the class
317
	 * name with an upper case character and continue only with lower case characters
318
	 * or numbers. Avoid chamel case names like "MyManager"!
319
	 *
320
	 * @param string Last part of the class name
321
	 * @since 2015.10
322
	 */
323
324
	/** mshop/attribute/manager/decorators/excludes
325
	 * Excludes decorators added by the "common" option from the attribute manager
326
	 *
327
	 * Decorators extend the functionality of a class by adding new aspects
328
	 * (e.g. log what is currently done), executing the methods of the underlying
329
	 * class only in certain conditions (e.g. only for logged in users) or
330
	 * modify what is returned to the caller.
331
	 *
332
	 * This option allows you to remove a decorator added via
333
	 * "mshop/common/manager/decorators/default" before they are wrapped
334
	 * around the attribute manager.
335
	 *
336
	 *  mshop/attribute/manager/decorators/excludes = array( 'decorator1' )
337
	 *
338
	 * This would remove the decorator named "decorator1" from the list of
339
	 * common decorators ("\Aimeos\MShop\Common\Manager\Decorator\*") added via
340
	 * "mshop/common/manager/decorators/default" for the attribute manager.
341
	 *
342
	 * @param array List of decorator names
343
	 * @since 2015.10
344
	 * @see mshop/common/manager/decorators/default
345
	 * @see mshop/attribute/manager/decorators/global
346
	 * @see mshop/attribute/manager/decorators/local
347
	 */
348
349
	/** mshop/attribute/manager/decorators/global
350
	 * Adds a list of globally available decorators only to the attribute manager
351
	 *
352
	 * Decorators extend the functionality of a class by adding new aspects
353
	 * (e.g. log what is currently done), executing the methods of the underlying
354
	 * class only in certain conditions (e.g. only for logged in users) or
355
	 * modify what is returned to the caller.
356
	 *
357
	 * This option allows you to wrap global decorators
358
	 * ("\Aimeos\MShop\Common\Manager\Decorator\*") around the attribute manager.
359
	 *
360
	 *  mshop/attribute/manager/decorators/global = array( 'decorator1' )
361
	 *
362
	 * This would add the decorator named "decorator1" defined by
363
	 * "\Aimeos\MShop\Common\Manager\Decorator\Decorator1" only to the attribute controller.
364
	 *
365
	 * @param array List of decorator names
366
	 * @since 2015.10
367
	 * @see mshop/common/manager/decorators/default
368
	 * @see mshop/attribute/manager/decorators/excludes
369
	 * @see mshop/attribute/manager/decorators/local
370
	 */
371
372
	/** mshop/attribute/manager/decorators/local
373
	 * Adds a list of local decorators only to the attribute manager
374
	 *
375
	 * Decorators extend the functionality of a class by adding new aspects
376
	 * (e.g. log what is currently done), executing the methods of the underlying
377
	 * class only in certain conditions (e.g. only for logged in users) or
378
	 * modify what is returned to the caller.
379
	 *
380
	 * This option allows you to wrap local decorators
381
	 * ("\Aimeos\MShop\Attribute\Manager\Decorator\*") around the attribute manager.
382
	 *
383
	 *  mshop/attribute/manager/decorators/local = array( 'decorator2' )
384
	 *
385
	 * This would add the decorator named "decorator2" defined by
386
	 * "\Aimeos\MShop\Attribute\Manager\Decorator\Decorator2" only to the attribute
387
	 * controller.
388
	 *
389
	 * @param array List of decorator names
390
	 * @since 2015.10
391
	 * @see mshop/common/manager/decorators/default
392
	 * @see mshop/attribute/manager/decorators/excludes
393
	 * @see mshop/attribute/manager/decorators/global
394
	 */
395
396
	/** mshop/attribute/manager/delete/mysql
397
	 * Deletes the items matched by the given IDs from the database
398
	 *
399
	 * @see mshop/attribute/manager/delete/ansi
400
	 */
401
402
	/** mshop/attribute/manager/delete/ansi
403
	 * Deletes the items matched by the given IDs from the database
404
	 *
405
	 * Removes the records specified by the given IDs from the attribute database.
406
	 * The records must be from the site that is configured via the
407
	 * context item.
408
	 *
409
	 * The ":cond" placeholder is replaced by the name of the ID column and
410
	 * the given ID or list of IDs while the site ID is bound to the question
411
	 * mark.
412
	 *
413
	 * The SQL statement should conform to the ANSI standard to be
414
	 * compatible with most relational database systems. This also
415
	 * includes using double quotes for table and column names.
416
	 *
417
	 * @param string SQL statement for deleting items
418
	 * @since 2015.10
419
	 * @see mshop/attribute/manager/insert/ansi
420
	 * @see mshop/attribute/manager/update/ansi
421
	 * @see mshop/attribute/manager/newid/ansi
422
	 * @see mshop/attribute/manager/search/ansi
423
	 * @see mshop/attribute/manager/count/ansi
424
	 */
425
426
	/** mshop/attribute/manager/insert/mysql
427
	 * Inserts a new attribute record into the database table
428
	 *
429
	 * @see mshop/attribute/manager/insert/ansi
430
	 */
431
432
	/** mshop/attribute/manager/insert/ansi
433
	 * Inserts a new attribute record into the database table
434
	 *
435
	 * Items with no ID yet (i.e. the ID is NULL) will be created in
436
	 * the database and the newly created ID retrieved afterwards
437
	 * using the "newid" SQL statement.
438
	 *
439
	 * The SQL statement must be a string suitable for being used as
440
	 * prepared statement. It must include question marks for binding
441
	 * the values from the attribute item to the statement before they are
442
	 * sent to the database server. The number of question marks must
443
	 * be the same as the number of columns listed in the INSERT
444
	 * statement. The order of the columns must correspond to the
445
	 * order in the save() method, so the correct values are
446
	 * bound to the columns.
447
	 *
448
	 * The SQL statement should conform to the ANSI standard to be
449
	 * compatible with most relational database systems. This also
450
	 * includes using double quotes for table and column names.
451
	 *
452
	 * @param string SQL statement for inserting records
453
	 * @since 2015.10
454
	 * @see mshop/attribute/manager/update/ansi
455
	 * @see mshop/attribute/manager/newid/ansi
456
	 * @see mshop/attribute/manager/delete/ansi
457
	 * @see mshop/attribute/manager/search/ansi
458
	 * @see mshop/attribute/manager/count/ansi
459
	 */
460
461
	/** mshop/attribute/manager/update/mysql
462
	 * Updates an existing attribute record in the database
463
	 *
464
	 * @see mshop/attribute/manager/update/ansi
465
	 */
466
467
	/** mshop/attribute/manager/update/ansi
468
	 * Updates an existing attribute record in the database
469
	 *
470
	 * Items which already have an ID (i.e. the ID is not NULL) will
471
	 * be updated in the database.
472
	 *
473
	 * The SQL statement must be a string suitable for being used as
474
	 * prepared statement. It must include question marks for binding
475
	 * the values from the attribute item to the statement before they are
476
	 * sent to the database server. The order of the columns must
477
	 * correspond to the order in the save() method, so the
478
	 * correct values are bound to the columns.
479
	 *
480
	 * The SQL statement should conform to the ANSI standard to be
481
	 * compatible with most relational database systems. This also
482
	 * includes using double quotes for table and column names.
483
	 *
484
	 * @param string SQL statement for updating records
485
	 * @since 2015.10
486
	 * @see mshop/attribute/manager/insert/ansi
487
	 * @see mshop/attribute/manager/newid/ansi
488
	 * @see mshop/attribute/manager/delete/ansi
489
	 * @see mshop/attribute/manager/search/ansi
490
	 * @see mshop/attribute/manager/count/ansi
491
	 */
492
493
	/** mshop/attribute/manager/newid/mysql
494
	 * Retrieves the ID generated by the database when inserting a new record
495
	 *
496
	 * @see mshop/attribute/manager/newid/ansi
497
	 */
498
499
	/** mshop/attribute/manager/newid/ansi
500
	 * Retrieves the ID generated by the database when inserting a new record
501
	 *
502
	 * As soon as a new record is inserted into the database table,
503
	 * the database server generates a new and unique identifier for
504
	 * that record. This ID can be used for retrieving, updating and
505
	 * deleting that specific record from the table again.
506
	 *
507
	 * For MySQL:
508
	 *  SELECT LAST_INSERT_ID()
509
	 * For PostgreSQL:
510
	 *  SELECT currval('seq_matt_id')
511
	 * For SQL Server:
512
	 *  SELECT SCOPE_IDENTITY()
513
	 * For Oracle:
514
	 *  SELECT "seq_matt_id".CURRVAL FROM DUAL
515
	 *
516
	 * There's no way to retrive the new ID by a SQL statements that
517
	 * fits for most database servers as they implement their own
518
	 * specific way.
519
	 *
520
	 * @param string SQL statement for retrieving the last inserted record ID
521
	 * @since 2015.10
522
	 * @see mshop/attribute/manager/insert/ansi
523
	 * @see mshop/attribute/manager/update/ansi
524
	 * @see mshop/attribute/manager/delete/ansi
525
	 * @see mshop/attribute/manager/search/ansi
526
	 * @see mshop/attribute/manager/count/ansi
527
	 */
528
529
	/** mshop/attribute/manager/sitemode
530
	 * Mode how items from levels below or above in the site tree are handled
531
	 *
532
	 * By default, only items from the current site are fetched from the
533
	 * storage. If the ai-sites extension is installed, you can create a
534
	 * tree of sites. Then, this setting allows you to define for the
535
	 * whole attribute domain if items from parent sites are inherited,
536
	 * sites from child sites are aggregated or both.
537
	 *
538
	 * Available constants for the site mode are:
539
	 * * 0 = only items from the current site
540
	 * * 1 = inherit items from parent sites
541
	 * * 2 = aggregate items from child sites
542
	 * * 3 = inherit and aggregate items at the same time
543
	 *
544
	 * You also need to set the mode in the locale manager
545
	 * (mshop/locale/manager/sitelevel) to one of the constants.
546
	 * If you set it to the same value, it will work as described but you
547
	 * can also use different modes. For example, if inheritance and
548
	 * aggregation is configured the locale manager but only inheritance
549
	 * in the domain manager because aggregating items makes no sense in
550
	 * this domain, then items wil be only inherited. Thus, you have full
551
	 * control over inheritance and aggregation in each domain.
552
	 *
553
	 * @param int Constant from Aimeos\MShop\Locale\Manager\Base class
554
	 * @since 2018.01
555
	 * @see mshop/locale/manager/sitelevel
556
	 */
557
558
	/** mshop/attribute/manager/search/mysql
559
	 * Retrieves the records matched by the given criteria in the database
560
	 *
561
	 * @see mshop/attribute/manager/search/ansi
562
	 */
563
564
	/** mshop/attribute/manager/search/ansi
565
	 * Retrieves the records matched by the given criteria in the database
566
	 *
567
	 * Fetches the records matched by the given criteria from the attribute
568
	 * database. The records must be from one of the sites that are
569
	 * configured via the context item. If the current site is part of
570
	 * a tree of sites, the SELECT statement can retrieve all records
571
	 * from the current site and the complete sub-tree of sites.
572
	 *
573
	 * As the records can normally be limited by criteria from sub-managers,
574
	 * their tables must be joined in the SQL context. This is done by
575
	 * using the "internaldeps" property from the definition of the ID
576
	 * column of the sub-managers. These internal dependencies specify
577
	 * the JOIN between the tables and the used columns for joining. The
578
	 * ":joins" placeholder is then replaced by the JOIN strings from
579
	 * the sub-managers.
580
	 *
581
	 * To limit the records matched, conditions can be added to the given
582
	 * criteria object. It can contain comparisons like column names that
583
	 * must match specific values which can be combined by AND, OR or NOT
584
	 * operators. The resulting string of SQL conditions replaces the
585
	 * ":cond" placeholder before the statement is sent to the database
586
	 * server.
587
	 *
588
	 * If the records that are retrieved should be ordered by one or more
589
	 * columns, the generated string of column / sort direction pairs
590
	 * replaces the ":order" placeholder. Columns of
591
	 * sub-managers can also be used for ordering the result set but then
592
	 * no index can be used.
593
	 *
594
	 * The number of returned records can be limited and can start at any
595
	 * number between the begining and the end of the result set. For that
596
	 * the ":size" and ":start" placeholders are replaced by the
597
	 * corresponding values from the criteria object. The default values
598
	 * are 0 for the start and 100 for the size value.
599
	 *
600
	 * The SQL statement should conform to the ANSI standard to be
601
	 * compatible with most relational database systems. This also
602
	 * includes using double quotes for table and column names.
603
	 *
604
	 * @param string SQL statement for searching items
605
	 * @since 2015.10
606
	 * @see mshop/attribute/manager/insert/ansi
607
	 * @see mshop/attribute/manager/update/ansi
608
	 * @see mshop/attribute/manager/newid/ansi
609
	 * @see mshop/attribute/manager/delete/ansi
610
	 * @see mshop/attribute/manager/count/ansi
611
	 */
612
613
	/** mshop/attribute/manager/count/mysql
614
	 * Counts the number of records matched by the given criteria in the database
615
	 *
616
	 * @see mshop/attribute/manager/count/ansi
617
	 */
618
619
	/** mshop/attribute/manager/count/ansi
620
	 * Counts the number of records matched by the given criteria in the database
621
	 *
622
	 * Counts all records matched by the given criteria from the attribute
623
	 * database. The records must be from one of the sites that are
624
	 * configured via the context item. If the current site is part of
625
	 * a tree of sites, the statement can count all records from the
626
	 * current site and the complete sub-tree of sites.
627
	 *
628
	 * As the records can normally be limited by criteria from sub-managers,
629
	 * their tables must be joined in the SQL context. This is done by
630
	 * using the "internaldeps" property from the definition of the ID
631
	 * column of the sub-managers. These internal dependencies specify
632
	 * the JOIN between the tables and the used columns for joining. The
633
	 * ":joins" placeholder is then replaced by the JOIN strings from
634
	 * the sub-managers.
635
	 *
636
	 * To limit the records matched, conditions can be added to the given
637
	 * criteria object. It can contain comparisons like column names that
638
	 * must match specific values which can be combined by AND, OR or NOT
639
	 * operators. The resulting string of SQL conditions replaces the
640
	 * ":cond" placeholder before the statement is sent to the database
641
	 * server.
642
	 *
643
	 * Both, the strings for ":joins" and for ":cond" are the same as for
644
	 * the "search" SQL statement.
645
	 *
646
	 * Contrary to the "search" statement, it doesn't return any records
647
	 * but instead the number of records that have been found. As counting
648
	 * thousands of records can be a long running task, the maximum number
649
	 * of counted records is limited for performance reasons.
650
	 *
651
	 * The SQL statement should conform to the ANSI standard to be
652
	 * compatible with most relational database systems. This also
653
	 * includes using double quotes for table and column names.
654
	 *
655
	 * @param string SQL statement for counting items
656
	 * @since 2015.10
657
	 * @see mshop/attribute/manager/insert/ansi
658
	 * @see mshop/attribute/manager/update/ansi
659
	 * @see mshop/attribute/manager/newid/ansi
660
	 * @see mshop/attribute/manager/delete/ansi
661
	 * @see mshop/attribute/manager/search/ansi
662
 */
663
}
664