# defender-security/6.3.0/src/class-db.php

Defender Security – Malware Scanner, Login Security &amp; Firewall, version 6.3.0. 73 lines.

- Page: https://pluginprobe.com/plugins/defender-security/6.3.0/code/src/class-db.php
- Raw: https://pluginprobe.com/plugins/defender-security/6.3.0/raw/src/class-db.php
- Modified: 2026-09-29T07:49:52+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/defender-security/6.3.0/code/src/class-db.php#L10-L20`.

```php
<?php
/**
 * Handles database operations.
 *
 * @package WP_Defender
 */

namespace WP_Defender;

use Calotes\DB\Mapper;
use Calotes\Base\Model;
use ReflectionException;

/**
 * Contains methods for saving the current instance, getting the ORM, and retrieving the table name.
 */
class DB extends Model {

	/**
	 * Constructor for the class.
	 * Initializes the object by parsing annotations.
	 *
	 * @return void
	 */
	public function __construct() {
		$this->parse_annotations();
	}

	/**
	 * Save the current instance.
	 *
	 * @return false|int
	 */
	public function save(): bool|int {
		try {
			return self::get_orm()->save( $this );
		} catch ( \Throwable $e ) {
			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
				$this->log(
					sprintf(
						'Failed to save %s: %s in %s:%d',
						static::class,
						$e->getMessage(),
						$e->getFile(),
						$e->getLine()
					),
					'db-save-error.log'
				);
			}

			return false;
		}
	}

	/**
	 * Retrieves the ORM instance from the dependency injection container.
	 *
	 * @return Mapper The ORM instance.
	 */
	protected static function get_orm(): Mapper {
		return wd_di()->get( Mapper::class );
	}

	/**
	 * Get table name.
	 *
	 * @return string
	 */
	public function get_table(): string {
		return $this->table;
	}
}

```
