Use new code style
This commit is contained in:
@ -107,7 +107,5 @@ class Product_Query extends Query {
|
||||
public function __construct($query = array()) {
|
||||
|
||||
parent::__construct($query);
|
||||
|
||||
} // end __construct;
|
||||
|
||||
} // end class Product_Query;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace WP_Ultimo\Database\Products;
|
||||
// Exit if accessed directly
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
use \WP_Ultimo\Database\Engine\Enum;
|
||||
use WP_Ultimo\Database\Engine\Enum;
|
||||
|
||||
/**
|
||||
* Product Types.
|
||||
@ -43,8 +43,7 @@ class Product_Type extends Enum {
|
||||
static::PACKAGE => 'wu-bg-gray-200 wu-text-blue-700',
|
||||
static::SERVICE => 'wu-bg-yellow-200 wu-text-yellow-700',
|
||||
);
|
||||
|
||||
} // end classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with values => labels.
|
||||
@ -59,7 +58,5 @@ class Product_Type extends Enum {
|
||||
static::PACKAGE => __('Package', 'wp-ultimo'),
|
||||
static::SERVICE => __('Service', 'wp-ultimo'),
|
||||
);
|
||||
|
||||
} // end labels;
|
||||
|
||||
} // end class Product_Type;
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Products_Meta_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'productmeta';
|
||||
|
||||
/**
|
||||
@ -55,8 +55,7 @@ final class Products_Meta_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -76,7 +75,5 @@ final class Products_Meta_Table extends Table {
|
||||
PRIMARY KEY (meta_id),
|
||||
KEY wu_product_id (wu_product_id),
|
||||
KEY meta_key (meta_key({$max_index_length}))";
|
||||
|
||||
} // end set_schema;
|
||||
|
||||
} // end class Products_Meta_Table;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class Products_Schema extends Schema {
|
||||
'unsigned' => true,
|
||||
'extra' => 'auto_increment',
|
||||
'primary' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -70,14 +70,14 @@ class Products_Schema extends Schema {
|
||||
'name' => 'name',
|
||||
'type' => 'varchar',
|
||||
'searchable' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'name' => 'description',
|
||||
'type' => 'longtext',
|
||||
'default' => '',
|
||||
'searchable' => true
|
||||
'searchable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -93,7 +93,7 @@ class Products_Schema extends Schema {
|
||||
'type' => 'varchar',
|
||||
'length' => '10',
|
||||
'default' => 'USD',
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -101,7 +101,7 @@ class Products_Schema extends Schema {
|
||||
'type' => 'varchar',
|
||||
'length' => '10',
|
||||
'default' => 'paid',
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -136,7 +136,7 @@ class Products_Schema extends Schema {
|
||||
'unsigned' => true,
|
||||
'default' => '0',
|
||||
'sortable' => true,
|
||||
'transition' => true
|
||||
'transition' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -151,7 +151,7 @@ class Products_Schema extends Schema {
|
||||
'unsigned' => true,
|
||||
'default' => '0',
|
||||
'sortable' => true,
|
||||
'transition' => true
|
||||
'transition' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -166,7 +166,7 @@ class Products_Schema extends Schema {
|
||||
'unsigned' => true,
|
||||
'default' => '0',
|
||||
'sortable' => true,
|
||||
'transition' => true
|
||||
'transition' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
@ -213,9 +213,8 @@ class Products_Schema extends Schema {
|
||||
'name' => 'type',
|
||||
'type' => 'varchar',
|
||||
'searchable' => true,
|
||||
'sortable' => true
|
||||
'sortable' => true,
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
} // end class Products_Schema;
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ defined('ABSPATH') || exit;
|
||||
final class Products_Table extends Table {
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
* Table name
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'products';
|
||||
|
||||
/**
|
||||
@ -66,8 +66,7 @@ final class Products_Table extends Table {
|
||||
public function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
} // end __construct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the database schema
|
||||
@ -101,8 +100,7 @@ final class Products_Table extends Table {
|
||||
date_created datetime NULL,
|
||||
date_modified datetime NULL,
|
||||
PRIMARY KEY (id)";
|
||||
|
||||
} // end set_schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the product_group column.
|
||||
@ -119,17 +117,14 @@ final class Products_Table extends Table {
|
||||
|
||||
// Maybe add column
|
||||
if (empty($result)) {
|
||||
|
||||
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `product_group` varchar(20) default '' AFTER `description`;";
|
||||
|
||||
$result = $this->get_db()->query($query);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
// Return success/fail
|
||||
return $this->is_success($result);
|
||||
|
||||
} // end __20210419;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the product_group column.
|
||||
@ -143,27 +138,22 @@ final class Products_Table extends Table {
|
||||
|
||||
// Maybe add column
|
||||
if (empty($result)) {
|
||||
|
||||
$query_set = "SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';";
|
||||
|
||||
$result_set = $this->get_db()->query($query_set);
|
||||
|
||||
if ($this->is_success($result_set) === false) {
|
||||
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
$query = "ALTER TABLE {$this->table_name} ADD COLUMN `product_group` varchar(20) default '' AFTER `description`;";
|
||||
|
||||
$result = $this->get_db()->query($query);
|
||||
|
||||
} // end if;
|
||||
}
|
||||
|
||||
// Return success/fail
|
||||
return $this->is_success($result);
|
||||
|
||||
} // end __20210607;
|
||||
}
|
||||
/**
|
||||
* Fixes the datetime columns to accept null.
|
||||
*
|
||||
@ -177,21 +167,15 @@ final class Products_Table extends Table {
|
||||
);
|
||||
|
||||
foreach ($null_columns as $column) {
|
||||
|
||||
$query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;";
|
||||
|
||||
$result = $this->get_db()->query($query);
|
||||
|
||||
if (!$this->is_success($result)) {
|
||||
|
||||
if ( ! $this->is_success($result)) {
|
||||
return false;
|
||||
|
||||
} // end if;
|
||||
|
||||
} // end foreach;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} // end __20230601;
|
||||
|
||||
} // end class Products_Table;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user