• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aimeos / aimeos-core / db1927f1-cdf2-4228-b63a-69c0db0f6f19

11 Oct 2024 11:08AM UTC coverage: 91.635% (-0.006%) from 91.641%
db1927f1-cdf2-4228-b63a-69c0db0f6f19

push

circleci

aimeos
Fixed backward compatibility

6 of 7 new or added lines in 2 files covered. (85.71%)

4 existing lines in 1 file now uncovered.

9552 of 10424 relevant lines covered (91.63%)

80.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/src/MShop/Subscription/Manager/Standard.php
1
<?php
2

3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2018-2024
6
 * @package MShop
7
 * @subpackage Subscription
8
 */
9

10

11
namespace Aimeos\MShop\Subscription\Manager;
12

13

14
/**
15
 * Default subscription manager implementation
16
 *
17
 * @package MShop
18
 * @subpackage Subscription
19
 */
20
class Standard
21
        extends \Aimeos\MShop\Common\Manager\Base
22
        implements \Aimeos\MShop\Subscription\Manager\Iface, \Aimeos\MShop\Common\Manager\Factory\Iface
23
{
24
        private array $searchConfig = [
25
                'subscription.orderid' => [
26
                        'label' => 'Order ID',
27
                        'internalcode' => 'orderid',
28
                        'type' => 'int',
29
                        'public' => false,
30
                ],
31
                'subscription.ordprodid' => [
32
                        'label' => 'Order product ID',
33
                        'internalcode' => 'ordprodid',
34
                        'type' => 'int',
35
                        'public' => false,
36
                ],
37
                'subscription.datenext' => [
38
                        'label' => 'Next renewal date/time',
39
                        'internalcode' => 'next',
40
                        'type' => 'datetime',
41
                ],
42
                'subscription.dateend' => [
43
                        'label' => 'End of subscription',
44
                        'internalcode' => 'end',
45
                        'type' => 'datetime',
46
                ],
47
                'subscription.interval' => [
48
                        'label' => 'Renewal interval',
49
                        'internalcode' => 'interval',
50
                ],
51
                'subscription.reason' => [
52
                        'label' => 'Subscription end reason',
53
                        'internalcode' => 'reason',
54
                        'type' => 'int',
55
                ],
56
                'subscription.period' => [
57
                        'label' => 'Subscription period count',
58
                        'internalcode' => 'period',
59
                        'type' => 'int',
60
                ],
61
                'subscription.productid' => [
62
                        'label' => 'Subscription product ID',
63
                        'internalcode' => 'productid',
64
                ],
65
                'subscription.status' => [
66
                        'label' => 'Subscription status',
67
                        'internalcode' => 'status',
68
                        'type' => 'int',
69
                ],
70
        ];
71

72

73
        /**
74
         * Creates the manager that will use the given context object.
75
         *
76
         * @param \Aimeos\MShop\ContextIface $context Context object with required objects
77
         */
78
        public function __construct( \Aimeos\MShop\ContextIface $context )
79
        {
80
                parent::__construct( $context );
17✔
81

82
                /** mshop/subscription/manager/resource
83
                 * Name of the database connection resource to use
84
                 *
85
                 * You can configure a different database connection for each data domain
86
                 * and if no such connection name exists, the "db" connection will be used.
87
                 * It's also possible to use the same database connection for different
88
                 * data domains by configuring the same connection name using this setting.
89
                 *
90
                 * @param string Database connection name
91
                 * @since 2023.04
92
                 */
93
                $this->setResourceName( $context->config()->get( 'mshop/subscription/manager/resource', 'db-order' ) );
17✔
94
        }
95

96

97
        /**
98
         * Counts the number items that are available for the values of the given key.
99
         *
100
         * @param \Aimeos\Base\Criteria\Iface $search Search criteria
101
         * @param array|string $key Search key or list of keys to aggregate items for
102
         * @param string|null $value Search key for aggregating the value column
103
         * @param string|null $type Type of the aggregation, empty string for count or "sum" or "avg" (average)
104
         * @return \Aimeos\Map List of the search keys as key and the number of counted items as value
105
         */
106
        public function aggregate( \Aimeos\Base\Criteria\Iface $search, $key, string $value = null, string $type = null ) : \Aimeos\Map
107
        {
108
                /** mshop/subscription/manager/aggregate/mysql
109
                 * Counts the number of records grouped by the values in the key column and matched by the given criteria
110
                 *
111
                 * @see mshop/subscription/manager/aggregate/ansi
112
                 */
113

114
                /** mshop/subscription/manager/aggregate/ansi
115
                 * Counts the number of records grouped by the values in the key column and matched by the given criteria
116
                 *
117
                 * Groups all records by the values in the key column and counts their
118
                 * occurence. The matched records can be limited by the given criteria
119
                 * from the subscription database. The records must be from one of the sites
120
                 * that are configured via the context item. If the current site is part
121
                 * of a tree of sites, the statement can count all records from the
122
                 * current site and the complete sub-tree of sites.
123
                 *
124
                 * As the records can normally be limited by criteria from sub-managers,
125
                 * their tables must be joined in the SQL context. This is done by
126
                 * using the "internaldeps" property from the definition of the ID
127
                 * column of the sub-managers. These internal dependencies specify
128
                 * the JOIN between the tables and the used columns for joining. The
129
                 * ":joins" placeholder is then replaced by the JOIN strings from
130
                 * the sub-managers.
131
                 *
132
                 * To limit the records matched, conditions can be added to the given
133
                 * criteria object. It can contain comparisons like column names that
134
                 * must match specific values which can be combined by AND, OR or NOT
135
                 * operators. The resulting string of SQL conditions replaces the
136
                 * ":cond" placeholder before the statement is sent to the database
137
                 * server.
138
                 *
139
                 * This statement doesn't return any records. Instead, it returns pairs
140
                 * of the different values found in the key column together with the
141
                 * number of records that have been found for that key values.
142
                 *
143
                 * The SQL statement should conform to the ANSI standard to be
144
                 * compatible with most relational database systems. This also
145
                 * includes using double quotes for table and column names.
146
                 *
147
                 * @param string SQL statement for aggregating subscription items
148
                 * @since 2018.04
149
                 * @see mshop/subscription/manager/insert/ansi
150
                 * @see mshop/subscription/manager/update/ansi
151
                 * @see mshop/subscription/manager/newid/ansi
152
                 * @see mshop/subscription/manager/delete/ansi
153
                 * @see mshop/subscription/manager/search/ansi
154
                 * @see mshop/subscription/manager/count/ansi
155
                 */
156

157
                $cfgkey = 'mshop/subscription/manager/aggregate';
1✔
158
                return $this->aggregateBase( $search, $key, $cfgkey, ['subscription'], $value, $type );
1✔
159
        }
160

161

162
        /**
163
         * Creates a new empty item instance
164
         *
165
         * @param array $values Values the item should be initialized with
166
         * @return \Aimeos\MShop\Subscription\Item\Iface New subscription item object
167
         */
168
        public function create( array $values = [] ) : \Aimeos\MShop\Common\Item\Iface
169
        {
170
                $values['subscription.siteid'] = $values['subscription.siteid'] ?? $this->context()->locale()->getSiteId();
6✔
171
                return new \Aimeos\MShop\Subscription\Item\Standard( 'subscription.', $values );
6✔
172
        }
173

174

175
        /**
176
         * Creates a filter object.
177
         *
178
         * @param bool|null $default Add default criteria or NULL for relaxed default criteria
179
         * @param bool $site TRUE for adding site criteria to limit items by the site of related items
180
         * @return \Aimeos\Base\Criteria\Iface Returns the filter object
181
         */
182
        public function filter( ?bool $default = false, bool $site = false ) : \Aimeos\Base\Criteria\Iface
183
        {
184
                $filter = $this->filterBase( 'subscription', $default );
10✔
185

186
                if( $site )
10✔
187
                {
188
                        $level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
1✔
189
                        $filter->add( $this->siteCondition( 'order.product.siteid', $level ) );
1✔
190
                }
191

192
                return $filter;
10✔
193
        }
194

195

196
        /**
197
         * Returns the additional column/search definitions
198
         *
199
         * @return array Associative list of column names as keys and items implementing \Aimeos\Base\Criteria\Attribute\Iface
200
         */
201
        public function getSaveAttributes() : array
202
        {
203
                return $this->createAttributes( $this->searchConfig );
6✔
204
        }
205

206

207
        /**
208
         * Returns the attributes that can be used for searching.
209
         *
210
         * @param bool $withsub Return also attributes of sub-managers if true
211
         * @return \Aimeos\Base\Criteria\Attribute\Iface[] List of search attribute items
212
         */
213
        public function getSearchAttributes( bool $withsub = true ) : array
214
        {
215
                $list = parent::getSearchAttributes( $withsub );
6✔
216

217
                if( $withsub ) {
6✔
218
                        $list += \Aimeos\MShop::create( $this->context(), 'order' )->getSearchAttributes( $withsub );
6✔
219
                }
220

221
                return $list;
6✔
222
        }
223

224

225
        /**
226
         * Searches for subscriptions based on the given criteria.
227
         *
228
         * @param \Aimeos\Base\Criteria\Iface $search Search criteria object
229
         * @param string[] $ref List of domains to fetch list items and referenced items for
230
         * @param int|null &$total Number of items that are available in total
231
         * @return \Aimeos\Map List of items implementing \Aimeos\MShop\Subscription\Item\Iface with ids as keys
232
         */
233
        public function search( \Aimeos\Base\Criteria\Iface $search, array $ref = [], int &$total = null ) : \Aimeos\Map
234
        {
235
                $context = $this->context();
5✔
236

237
                /** mshop/subscription/manager/sitemode
238
                 * Mode how items from levels below or above in the site tree are handled
239
                 *
240
                 * By default, only items from the current site are fetched from the
241
                 * storage. If the ai-sites extension is installed, you can create a
242
                 * tree of sites. Then, this setting allows you to define for the
243
                 * whole subscription domain if items from parent sites are inherited,
244
                 * sites from child sites are aggregated or both.
245
                 *
246
                 * Available constants for the site mode are:
247
                 * * 0 = only items from the current site
248
                 * * 1 = inherit items from parent sites
249
                 * * 2 = aggregate items from child sites
250
                 * * 3 = inherit and aggregate items at the same time
251
                 *
252
                 * You also need to set the mode in the locale manager
253
                 * (mshop/locale/manager/sitelevel) to one of the constants.
254
                 * If you set it to the same value, it will work as described but you
255
                 * can also use different modes. For example, if inheritance and
256
                 * aggregation is configured the locale manager but only inheritance
257
                 * in the domain manager because aggregating items makes no sense in
258
                 * this domain, then items wil be only inherited. Thus, you have full
259
                 * control over inheritance and aggregation in each domain.
260
                 *
261
                 * @param int Constant from Aimeos\MShop\Locale\Manager\Base class
262
                 * @since 2018.04
263
                 * @see mshop/locale/manager/sitelevel
264
                 */
265
                $level = \Aimeos\MShop\Locale\Manager\Base::SITE_SUBTREE;
5✔
266
                $level = $context->config()->get( 'mshop/subscription/manager/sitemode', $level );
5✔
267

268
                /** mshop/subscription/manager/search/mysql
269
                 * Retrieves the records matched by the given criteria in the database
270
                 *
271
                 * @see mshop/subscription/manager/search/ansi
272
                 */
273

274
                /** mshop/subscription/manager/search/ansi
275
                 * Retrieves the records matched by the given criteria in the database
276
                 *
277
                 * Fetches the records matched by the given criteria from the subscription
278
                 * database. The records must be from one of the sites that are
279
                 * configured via the context item. If the current site is part of
280
                 * a tree of sites, the SELECT statement can retrieve all records
281
                 * from the current site and the complete sub-tree of sites.
282
                 *
283
                 * As the records can normally be limited by criteria from sub-managers,
284
                 * their tables must be joined in the SQL context. This is done by
285
                 * using the "internaldeps" property from the definition of the ID
286
                 * column of the sub-managers. These internal dependencies specify
287
                 * the JOIN between the tables and the used columns for joining. The
288
                 * ":joins" placeholder is then replaced by the JOIN strings from
289
                 * the sub-managers.
290
                 *
291
                 * To limit the records matched, conditions can be added to the given
292
                 * criteria object. It can contain comparisons like column names that
293
                 * must match specific values which can be combined by AND, OR or NOT
294
                 * operators. The resulting string of SQL conditions replaces the
295
                 * ":cond" placeholder before the statement is sent to the database
296
                 * server.
297
                 *
298
                 * If the records that are retrieved should be ordered by one or more
299
                 * columns, the generated string of column / sort direction pairs
300
                 * replaces the ":order" placeholder.
301
                 *
302
                 * The number of returned records can be limited and can start at any
303
                 * number between the begining and the end of the result set. For that
304
                 * the ":size" and ":start" placeholders are replaced by the
305
                 * corresponding values from the criteria object. The default values
306
                 * are 0 for the start and 100 for the size value.
307
                 *
308
                 * The SQL statement should conform to the ANSI standard to be
309
                 * compatible with most relational database systems. This also
310
                 * includes using double quotes for table and column names.
311
                 *
312
                 * @param string SQL statement for searching items
313
                 * @since 2018.04
314
                 * @see mshop/subscription/manager/insert/ansi
315
                 * @see mshop/subscription/manager/update/ansi
316
                 * @see mshop/subscription/manager/newid/ansi
317
                 * @see mshop/subscription/manager/delete/ansi
318
                 * @see mshop/subscription/manager/count/ansi
319
                 */
320
                $cfgPathSearch = 'mshop/subscription/manager/search';
5✔
321

322
                /** mshop/subscription/manager/count/mysql
323
                 * Counts the number of records matched by the given criteria in the database
324
                 *
325
                 * @see mshop/subscription/manager/count/ansi
326
                 */
327

328
                /** mshop/subscription/manager/count/ansi
329
                 * Counts the number of records matched by the given criteria in the database
330
                 *
331
                 * Counts all records matched by the given criteria from the subscription
332
                 * database. The records must be from one of the sites that are
333
                 * configured via the context item. If the current site is part of
334
                 * a tree of sites, the statement can count all records from the
335
                 * current site and the complete sub-tree of sites.
336
                 *
337
                 * As the records can normally be limited by criteria from sub-managers,
338
                 * their tables must be joined in the SQL context. This is done by
339
                 * using the "internaldeps" property from the definition of the ID
340
                 * column of the sub-managers. These internal dependencies specify
341
                 * the JOIN between the tables and the used columns for joining. The
342
                 * ":joins" placeholder is then replaced by the JOIN strings from
343
                 * the sub-managers.
344
                 *
345
                 * To limit the records matched, conditions can be added to the given
346
                 * criteria object. It can contain comparisons like column names that
347
                 * must match specific values which can be combined by AND, OR or NOT
348
                 * operators. The resulting string of SQL conditions replaces the
349
                 * ":cond" placeholder before the statement is sent to the database
350
                 * server.
351
                 *
352
                 * Both, the strings for ":joins" and for ":cond" are the same as for
353
                 * the "search" SQL statement.
354
                 *
355
                 * Contrary to the "search" statement, it doesn't return any records
356
                 * but instead the number of records that have been found. As counting
357
                 * thousands of records can be a long running task, the maximum number
358
                 * of counted records is limited for performance reasons.
359
                 *
360
                 * The SQL statement should conform to the ANSI standard to be
361
                 * compatible with most relational database systems. This also
362
                 * includes using double quotes for table and column names.
363
                 *
364
                 * @param string SQL statement for counting items
365
                 * @since 2018.04
366
                 * @see mshop/subscription/manager/insert/ansi
367
                 * @see mshop/subscription/manager/update/ansi
368
                 * @see mshop/subscription/manager/newid/ansi
369
                 * @see mshop/subscription/manager/delete/ansi
370
                 * @see mshop/subscription/manager/search/ansi
371
                 */
372
                $cfgPathCount = 'mshop/subscription/manager/count';
5✔
373

374
                $items = [];
5✔
375
                $required = ['subscription', 'order'];
5✔
376
                $conn = $context->db( $this->getResourceName() );
5✔
377
                $results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level );
5✔
378

379
                try
380
                {
381
                        while( $row = $results->fetch() )
5✔
382
                        {
383
                                if( $item = $this->applyFilter( $this->create( $row ) ) ) {
5✔
384
                                        $items[$row['subscription.id']] = $item;
5✔
385
                                }
386
                        }
387
                }
UNCOV
388
                catch( \Exception $e )
×
389
                {
UNCOV
390
                        $results->finish();
×
UNCOV
391
                        throw $e;
×
392
                }
393

394

395
                if( in_array( 'order', $ref ) )
5✔
396
                {
397
                        $ids = array_column( $items, 'subscription.orderid' );
1✔
398
                        $manager = \Aimeos\MShop::create( $context, 'order' );
1✔
399
                        $search = $manager->filter()->add( 'order.id', '==', $ids )->slice( 0, count( $ids ) );
1✔
400
                        $orderItems = $manager->search( $search, $ref );
1✔
401

402
                        foreach( $items as $item ) {
1✔
403
                                $item->set( '.orderitem', $orderItems[$item['subscription.orderid']] ?? null );
1✔
404
                        }
405
                }
406

407
                return map( $items );
5✔
408
        }
409

410

411
        /**
412
         * Returns the prefix for the item properties and search keys.
413
         *
414
         * @return string Prefix for the item properties and search keys
415
         */
416
        protected function prefix() : string
417
        {
418
                return 'subscription.';
6✔
419
        }
420

421

422
        /**
423
         * Creates a one-time subscription in the storage from the given invoice object.
424
         *
425
         * @param \Aimeos\MShop\Common\Item\Iface $item Subscription item with necessary values
426
         * @param bool $fetch True if the new ID should be returned in the item
427
         * @return \Aimeos\MShop\Subscription\Item\Iface Updated item including the generated ID
428
         */
429
        protected function saveBase( \Aimeos\MShop\Common\Item\Iface $item, bool $fetch = true ) : \Aimeos\MShop\Subscription\Item\Iface
430
        {
431
                if( $item->getOrderProductId() === null ) {
1✔
UNCOV
432
                        throw new \Aimeos\MShop\Subscription\Exception( 'Required order product ID is missing' );
×
433
                }
434

435
                if( $orderItem = $item->getOrderItem() ) {
1✔
436
                        \Aimeos\MShop::create( $this->context(), 'order' )->save( $orderItem );
×
437
                }
438

439
                return parent::saveBase( $item, $fetch );
1✔
440
        }
441

442

443
        /** mshop/subscription/manager/name
444
         * Class name of the used subscription manager implementation
445
         *
446
         * Each default manager can be replace by an alternative imlementation.
447
         * To use this implementation, you have to set the last part of the class
448
         * name as configuration value so the manager factory knows which class it
449
         * has to instantiate.
450
         *
451
         * For example, if the name of the default class is
452
         *
453
         *  \Aimeos\MShop\Subscription\Manager\Standard
454
         *
455
         * and you want to replace it with your own version named
456
         *
457
         *  \Aimeos\MShop\Subscription\Manager\Mymanager
458
         *
459
         * then you have to set the this configuration option:
460
         *
461
         *  mshop/subscription/manager/name = Mymanager
462
         *
463
         * The value is the last part of your own class name and it's case sensitive,
464
         * so take care that the configuration value is exactly named like the last
465
         * part of the class name.
466
         *
467
         * The allowed characters of the class name are A-Z, a-z and 0-9. No other
468
         * characters are possible! You should always start the last part of the class
469
         * name with an upper case character and continue only with lower case characters
470
         * or numbers. Avoid chamel case names like "MyManager"!
471
         *
472
         * @param string Last part of the class name
473
         * @since 2018.04
474
         */
475

476
        /** mshop/subscription/manager/decorators/excludes
477
         * Excludes decorators added by the "common" option from the subscription manager
478
         *
479
         * Decorators extend the functionality of a class by adding new aspects
480
         * (e.g. log what is currently done), executing the methods of the underlying
481
         * class only in certain conditions (e.g. only for logged in users) or
482
         * modify what is returned to the caller.
483
         *
484
         * This option allows you to remove a decorator added via
485
         * "mshop/common/manager/decorators/default" before they are wrapped
486
         * around the subscription manager.
487
         *
488
         *  mshop/subscription/manager/decorators/excludes = array( 'decorator1' )
489
         *
490
         * This would remove the decorator named "decorator1" from the list of
491
         * common decorators ("\Aimeos\MShop\Common\Manager\Decorator\*") added via
492
         * "mshop/common/manager/decorators/default" for the subscription manager.
493
         *
494
         * @param array List of decorator names
495
         * @since 2018.04
496
         * @see mshop/common/manager/decorators/default
497
         * @see mshop/subscription/manager/decorators/global
498
         * @see mshop/subscription/manager/decorators/local
499
         */
500

501
        /** mshop/subscription/manager/decorators/global
502
         * Adds a list of globally available decorators only to the subscription manager
503
         *
504
         * Decorators extend the functionality of a class by adding new aspects
505
         * (e.g. log what is currently done), executing the methods of the underlying
506
         * class only in certain conditions (e.g. only for logged in users) or
507
         * modify what is returned to the caller.
508
         *
509
         * This option allows you to wrap global decorators
510
         * ("\Aimeos\MShop\Common\Manager\Decorator\*") around the subscription manager.
511
         *
512
         *  mshop/subscription/manager/decorators/global = array( 'decorator1' )
513
         *
514
         * This would add the decorator named "decorator1" defined by
515
         * "\Aimeos\MShop\Common\Manager\Decorator\Decorator1" only to the subscription
516
         * manager.
517
         *
518
         * @param array List of decorator names
519
         * @since 2018.04
520
         * @see mshop/common/manager/decorators/default
521
         * @see mshop/subscription/manager/decorators/excludes
522
         * @see mshop/subscription/manager/decorators/local
523
         */
524

525
        /** mshop/subscription/manager/decorators/local
526
         * Adds a list of local decorators only to the subscription manager
527
         *
528
         * Decorators extend the functionality of a class by adding new aspects
529
         * (e.g. log what is currently done), executing the methods of the underlying
530
         * class only in certain conditions (e.g. only for logged in users) or
531
         * modify what is returned to the caller.
532
         *
533
         * This option allows you to wrap local decorators
534
         * ("\Aimeos\MShop\Subscription\Manager\Decorator\*") around the subscription manager.
535
         *
536
         *  mshop/subscription/manager/decorators/local = array( 'decorator2' )
537
         *
538
         * This would add the decorator named "decorator2" defined by
539
         * "\Aimeos\MShop\Subscription\Manager\Decorator\Decorator2" only to the subscription
540
         * manager.
541
         *
542
         * @param array List of decorator names
543
         * @since 2018.04
544
         * @see mshop/common/manager/decorators/default
545
         * @see mshop/subscription/manager/decorators/excludes
546
         * @see mshop/subscription/manager/decorators/global
547
         */
548

549
        /** mshop/subscription/manager/delete/mysql
550
         * Deletes the items matched by the given IDs from the database
551
         *
552
         * @see mshop/subscription/manager/delete/ansi
553
         */
554

555
        /** mshop/subscription/manager/delete/ansi
556
         * Deletes the items matched by the given IDs from the database
557
         *
558
         * Removes the records specified by the given IDs from the subscription database.
559
         * The records must be from the site that is configured via the
560
         * context item.
561
         *
562
         * The ":cond" placeholder is replaced by the name of the ID column and
563
         * the given ID or list of IDs while the site ID is bound to the question
564
         * mark.
565
         *
566
         * The SQL statement should conform to the ANSI standard to be
567
         * compatible with most relational database systems. This also
568
         * includes using double quotes for table and column names.
569
         *
570
         * @param string SQL statement for deleting items
571
         * @since 2018.04
572
         * @see mshop/subscription/manager/insert/ansi
573
         * @see mshop/subscription/manager/update/ansi
574
         * @see mshop/subscription/manager/newid/ansi
575
         * @see mshop/subscription/manager/search/ansi
576
         * @see mshop/subscription/manager/count/ansi
577
         */
578

579
        /** mshop/subscription/manager/submanagers
580
         * List of manager names that can be instantiated by the subscription manager
581
         *
582
         * Managers provide a generic interface to the underlying storage.
583
         * Each manager has or can have sub-managers caring about particular
584
         * aspects. Each of these sub-managers can be instantiated by its
585
         * parent manager using the getSubManager() method.
586
         *
587
         * The search keys from sub-managers can be normally used in the
588
         * manager as well. It allows you to search for items of the manager
589
         * using the search keys of the sub-managers to further limit the
590
         * retrieved list of items.
591
         *
592
         * @param array List of sub-manager names
593
         * @since 2018.04
594
         */
595

596
        /** mshop/subscription/manager/insert/mysql
597
         * Inserts a new subscription record into the database table
598
         *
599
         * @see mshop/subscription/manager/insert/ansi
600
         */
601

602
        /** mshop/subscription/manager/insert/ansi
603
         * Inserts a new subscription record into the database table
604
         *
605
         * Items with no ID yet (i.e. the ID is NULL) will be created in
606
         * the database and the newly created ID retrieved afterwards
607
         * using the "newid" SQL statement.
608
         *
609
         * The SQL statement must be a string suitable for being used as
610
         * prepared statement. It must include question marks for binding
611
         * the values from the subscription item to the statement before they are
612
         * sent to the database server. The number of question marks must
613
         * be the same as the number of columns listed in the INSERT
614
         * statement. The order of the columns must correspond to the
615
         * order in the save() method, so the correct values are
616
         * bound to the columns.
617
         *
618
         * The SQL statement should conform to the ANSI standard to be
619
         * compatible with most relational database systems. This also
620
         * includes using double quotes for table and column names.
621
         *
622
         * @param string SQL statement for inserting records
623
         * @since 2018.04
624
         * @see mshop/subscription/manager/update/ansi
625
         * @see mshop/subscription/manager/newid/ansi
626
         * @see mshop/subscription/manager/delete/ansi
627
         * @see mshop/subscription/manager/search/ansi
628
         * @see mshop/subscription/manager/count/ansi
629
         */
630

631
        /** mshop/subscription/manager/update/mysql
632
         * Updates an existing subscription record in the database
633
         *
634
         * @see mshop/subscription/manager/update/ansi
635
         */
636

637
        /** mshop/subscription/manager/update/ansi
638
         * Updates an existing subscription record in the database
639
         *
640
         * Items which already have an ID (i.e. the ID is not NULL) will
641
         * be updated in the database.
642
         *
643
         * The SQL statement must be a string suitable for being used as
644
         * prepared statement. It must include question marks for binding
645
         * the values from the subscription item to the statement before they are
646
         * sent to the database server. The order of the columns must
647
         * correspond to the order in the save() method, so the
648
         * correct values are bound to the columns.
649
         *
650
         * The SQL statement should conform to the ANSI standard to be
651
         * compatible with most relational database systems. This also
652
         * includes using double quotes for table and column names.
653
         *
654
         * @param string SQL statement for updating records
655
         * @since 2018.04
656
         * @see mshop/subscription/manager/insert/ansi
657
         * @see mshop/subscription/manager/newid/ansi
658
         * @see mshop/subscription/manager/delete/ansi
659
         * @see mshop/subscription/manager/search/ansi
660
         * @see mshop/subscription/manager/count/ansi
661
         */
662

663
        /** mshop/subscription/manager/newid/mysql
664
         * Retrieves the ID generated by the database when inserting a new record
665
         *
666
         * @see mshop/subscription/manager/newid/ansi
667
         */
668

669
        /** mshop/subscription/manager/newid/ansi
670
         * Retrieves the ID generated by the database when inserting a new record
671
         *
672
         * As soon as a new record is inserted into the database table,
673
         * the database server generates a new and unique identifier for
674
         * that record. This ID can be used for retrieving, updating and
675
         * deleting that specific record from the table again.
676
         *
677
         * For MySQL:
678
         *  SELECT LAST_INSERT_ID()
679
         * For PostgreSQL:
680
         *  SELECT currval('seq_mrul_id')
681
         * For SQL Server:
682
         *  SELECT SCOPE_IDENTITY()
683
         * For Oracle:
684
         *  SELECT "seq_mrul_id".CURRVAL FROM DUAL
685
         *
686
         * There's no way to retrive the new ID by a SQL statements that
687
         * fits for most database servers as they implement their own
688
         * specific way.
689
         *
690
         * @param string SQL statement for retrieving the last inserted record ID
691
         * @since 2018.04
692
         * @see mshop/subscription/manager/insert/ansi
693
         * @see mshop/subscription/manager/update/ansi
694
         * @see mshop/subscription/manager/delete/ansi
695
         * @see mshop/subscription/manager/search/ansi
696
         * @see mshop/subscription/manager/count/ansi
697
         */
698
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc