Passed
Push — master ( 01f5f1...8a4484 )
by Aimeos
04:51
created

Standard::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 29
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 29
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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
	 * Returns the additional column/search definitions
91
	 *
92
	 * @return array Associative list of column names as keys and items implementing \Aimeos\Base\Criteria\Attribute\Iface
93
	 */
94
	public function getSaveAttributes() : array
95
	{
96
		return $this->createAttributes( [
97
			'price.type' => [
98
				'label' => 'Price type ID',
99
				'internalcode' => 'type',
100
			],
101
			'price.currencyid' => [
102
				'label' => 'Price currency code',
103
				'internalcode' => 'currencyid',
104
			],
105
			'price.domain' => [
106
				'label' => 'Price domain',
107
				'internalcode' => 'domain',
108
			],
109
			'price.label' => [
110
				'label' => 'Price label',
111
				'internalcode' => 'label',
112
			],
113
			'price.quantity' => [
114
				'label' => 'Price quantity',
115
				'internalcode' => 'quantity',
116
				'type' => 'float',
117
			],
118
			'price.value' => [
119
				'label' => 'Price regular value',
120
				'internalcode' => 'value',
121
				'type' => 'decimal',
122
			],
123
			'price.costs' => [
124
				'label' => 'Price shipping costs',
125
				'internalcode' => 'costs',
126
				'type' => 'decimal',
127
			],
128
			'price.rebate' => [
129
				'label' => 'Price rebate amount',
130
				'internalcode' => 'rebate',
131
				'type' => 'decimal',
132
			],
133
			'price.taxrate' => [
134
				'label' => 'Price tax rates as JSON encoded string',
135
				'internalcode' => 'taxrate',
136
				'type' => 'json',
137
			],
138
			'price.taxrates' => [
139
				'label' => 'Price tax rates as JSON encoded string',
140
				'internalcode' => 'taxrate',
141
				'type' => 'json',
142
			],
143
			'price.status' => [
144
				'label' => 'Price status',
145
				'internalcode' => 'status',
146
				'type' => 'int',
147
			],
148
		] );
149
	}
150
151
152
	/**
153
	 * Returns the attributes that can be used for searching.
154
	 *
155
	 * @param bool $withsub Return also attributes of sub-managers if true
156
	 * @return \Aimeos\Base\Criteria\Attribute\Iface[] List of search attribute items
157
	 */
158
	public function getSearchAttributes( bool $withsub = true ) : array
159
	{
160
		$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
161
		$level = $this->context()->config()->get( 'mshop/price/manager/sitemode', $level );
162
163
		return array_replace( parent::getSearchAttributes( $withsub ), $this->createAttributes( [
164
			'price:has' => array(
165
				'code' => 'price:has()',
166
				'internalcode' => ':site AND :key AND mprili."id"',
167
				'internaldeps' => ['LEFT JOIN "mshop_price_list" AS mprili ON ( mprili."parentid" = mpri."id" )'],
168
				'label' => 'Price has list item, parameter(<domain>[,<list type>[,<reference ID>)]]',
169
				'type' => 'null',
170
				'public' => false,
171
				'function' => function( &$source, array $params ) use ( $level ) {
172
					$keys = [];
173
174
					foreach( (array) ( $params[1] ?? '' ) as $type ) {
175
						foreach( (array) ( $params[2] ?? '' ) as $id ) {
176
							$keys[] = $params[0] . '|' . ( $type ? $type . '|' : '' ) . $id;
177
						}
178
					}
179
180
					$sitestr = $this->siteString( 'mprili."siteid"', $level );
181
					$keystr = $this->toExpression( 'mprili."key"', $keys, ( $params[2] ?? null ) ? '==' : '=~' );
182
					$source = str_replace( [':site', ':key'], [$sitestr, $keystr], $source );
183
184
					return $params;
185
				}
186
			),
187
			'price:prop' => array(
188
				'code' => 'price:prop()',
189
				'internalcode' => ':site AND :key AND mpripr."id"',
190
				'internaldeps' => ['LEFT JOIN "mshop_price_property" AS mpripr ON ( mpripr."parentid" = mpri."id" )'],
191
				'label' => 'Price has property item, parameter(<property type>[,<language code>[,<property value>]])',
192
				'type' => 'null',
193
				'public' => false,
194
				'function' => function( &$source, array $params ) use ( $level ) {
195
					$keys = [];
196
					$langs = array_key_exists( 1, $params ) ? ( $params[1] ?? 'null' ) : '';
197
198
					foreach( (array) $langs as $lang ) {
199
						foreach( (array) ( $params[2] ?? '' ) as $val ) {
200
							$keys[] = substr( $params[0] . '|' . ( $lang === null ? 'null|' : ( $lang ? $lang . '|' : '' ) ) . $val, 0, 255 );
201
						}
202
					}
203
204
					$sitestr = $this->siteString( 'mpripr."siteid"', $level );
205
					$keystr = $this->toExpression( 'mpripr."key"', $keys, ( $params[2] ?? null ) ? '==' : '=~' );
206
					$source = str_replace( [':site', ':key'], [$sitestr, $keystr], $source );
207
208
					return $params;
209
				}
210
			),
211
		] ) );
212
	}
213
214
215
	/**
216
	 * Creates a filter object.
217
	 *
218
	 * @param bool|null $default Add default criteria or NULL for relaxed default criteria
219
	 * @param bool $site TRUE for adding site criteria to limit items by the site of related items
220
	 * @return \Aimeos\Base\Criteria\Iface Returns the filter object
221
	 */
222
	public function filter( ?bool $default = false, bool $site = false ) : \Aimeos\Base\Criteria\Iface
223
	{
224
		$filter = $this->filterBase( 'price', $default );
225
226
		if( $default !== false && ( $currencyid = $this->context()->locale()->getCurrencyId() ) !== null ) {
227
			$filter->add( 'price.currencyid', '==', $currencyid );
228
		}
229
230
		return $filter;
231
	}
232
233
234
	/**
235
	 * Fetches the rows from the database statement and returns the list of items.
236
	 *
237
	 * @param \Aimeos\Base\DB\Result\Iface $stmt Database statement object
238
	 * @param array $ref List of domains whose items should be fetched too
239
	 * @param string $prefix Prefix for the property names
240
	 * @param array $attrs List of attributes that should be decoded
241
	 * @return \Aimeos\Map List of items implementing \Aimeos\MShop\Common\Item\Iface
242
	 */
243
	protected function fetch( \Aimeos\Base\DB\Result\Iface $results, array $ref, string $prefix = '', array $attrs = [] ) : \Aimeos\Map
244
	{
245
		$map = $items = $parentIds = $propItems = [];
246
247
		while( $row = $results->fetch() )
248
		{
249
			foreach( $attrs as $code => $attr ) {
250
				$row[$code] = json_decode( $row[$code], true );
251
			}
252
253
			$map[$row['price.id']] = $row;
254
			$parentIds[] = $row['price.id'];
255
		}
256
257
		if( $this->hasRef( $ref, 'price/property' ) )
258
		{
259
			$name = 'price/property';
260
			$propTypes = isset( $ref[$name] ) && is_array( $ref[$name] ) ? $ref[$name] : null;
261
262
			$propItems = $this->getPropertyItems( $parentIds, 'price', $propTypes );
263
		}
264
265
		$listItems = map( $this->getListItems( $parentIds, $ref, 'price' ) )->groupBy( 'price.lists.parentid' );
266
267
		foreach( $map as $id => $row )
268
		{
269
			$row['.listitems'] = $listItems[$id] ?? [];
270
			$row['.propitems'] = $propItems[$id] ?? [];
271
272
			if( $item = $this->applyFilter( $this->create( $row ) ) ) {
273
				$items[$id] = $item;
274
			}
275
		}
276
277
		return map( $items );
278
	}
279
280
281
	/**
282
	 * Returns the prefix for the item properties and search keys.
283
	 *
284
	 * @return string Prefix for the item properties and search keys
285
	 */
286
	protected function prefix() : string
287
	{
288
		return 'price.';
289
	}
290
291
292
	/**
293
	 * Saves the dependent items of the item
294
	 *
295
	 * @param \Aimeos\MShop\Common\Item\Iface $item Item object
296
	 * @param bool $fetch True if the new ID should be returned in the item
297
	 * @return \Aimeos\MShop\Common\Item\Iface Updated item
298
	 */
299
	protected function saveDeps( \Aimeos\MShop\Common\Item\Iface $item, bool $fetch = true ) : \Aimeos\MShop\Common\Item\Iface
300
	{
301
		$item = $this->savePropertyItems( $item, 'price', $fetch );
302
		return $this->saveListItems( $item, 'price', $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\Price\Manag...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

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