PluginProbe
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More / 2.2.0
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More v2.2.0
2.3.0 2.2.0 2.1.1 2.1.0 2.0.0 1.10.0 1.9.1 1.9.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 All 59 releases
storeengine / includes / classes / abstract-model.php

abstract-model.php in StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More 2.2.0, at includes/classes/abstract-model.php

40 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace StoreEngine\Classes;
4
5 abstract class AbstractModel {
6 protected $wpdb;
7 protected string $table;
8 protected string $query;
9 protected string $prefix;
10 protected string $primary_key = 'ID';
11
12 public function __construct() {
13 global $wpdb;
14 $this->wpdb = $wpdb;
15 $this->prefix = $wpdb->prefix;
16 $this->table = $this->prefix . $this->table;
17 }
18
19 abstract public function save( array $args = [] );
20
21 abstract public function update( int $id, array $args );
22
23 abstract public function delete( ?int $id = null );
24
25 protected function create_item( array $data, ?array $format = null ) {
26 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
27 return $this->wpdb->insert( $this->table, $data, $format );
28 }
29
30 protected function update_item( array $data, array $where, ?array $format = null, ?array $where_format = null ) {
31 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
32 return $this->wpdb->update( $this->table, $data, $where, $format, $where_format );
33 }
34
35 protected function delete_item( array $where, ?array $format = null ) {
36 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
37 return $this->wpdb->delete( $this->table, $where, $format );
38 }
39 }
40