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

Standard::saveRefs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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