2018-11-15 18:10:52 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2019-02-26 19:46:33 +00:00
|
|
|
* FuzeWorks Component.
|
2018-11-15 18:10:52 +00:00
|
|
|
*
|
|
|
|
* The FuzeWorks PHP FrameWork
|
|
|
|
*
|
2019-02-26 19:46:33 +00:00
|
|
|
* Copyright (C) 2013-2019 TechFuze
|
2018-11-15 18:10:52 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*
|
|
|
|
* @author TechFuze
|
2019-02-26 19:46:33 +00:00
|
|
|
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
|
2018-11-15 18:10:52 +00:00
|
|
|
* @license https://opensource.org/licenses/MIT MIT License
|
|
|
|
*
|
|
|
|
* @link http://techfuze.net/fuzeworks
|
2019-02-26 19:46:33 +00:00
|
|
|
* @since Version 1.2.0
|
2018-11-15 18:10:52 +00:00
|
|
|
*
|
2019-02-26 19:46:33 +00:00
|
|
|
* @version Version 1.2.0
|
2018-11-15 18:10:52 +00:00
|
|
|
*/
|
|
|
|
|
2019-02-26 19:46:33 +00:00
|
|
|
namespace FuzeWorks\Model;
|
2019-08-21 14:42:47 +00:00
|
|
|
use FuzeWorks\DatabaseEngine\iDatabaseEngine;
|
2019-07-22 09:43:01 +00:00
|
|
|
use FuzeWorks\Exception\DatabaseException;
|
|
|
|
|
2019-02-26 19:46:33 +00:00
|
|
|
interface iDatabaseTableModel
|
|
|
|
{
|
2019-07-22 09:43:01 +00:00
|
|
|
/**
|
2019-09-08 18:32:42 +00:00
|
|
|
* Returns the name of the TableModel.
|
|
|
|
*
|
|
|
|
* Usually 'pdo' or 'mongo'.
|
|
|
|
*
|
2019-07-22 09:43:01 +00:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getName(): string;
|
|
|
|
|
2019-08-21 14:42:47 +00:00
|
|
|
/**
|
2019-09-08 18:32:42 +00:00
|
|
|
* Return the name of the engine used by this TableModel.
|
|
|
|
*
|
|
|
|
* Usually 'pdo' or 'mongo'
|
|
|
|
*
|
2019-08-21 14:42:47 +00:00
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getEngineName(): string;
|
|
|
|
|
2019-09-08 18:32:42 +00:00
|
|
|
/**
|
|
|
|
* Return the engine used by this TableModel
|
|
|
|
*
|
|
|
|
* @return iDatabaseEngine
|
|
|
|
*/
|
|
|
|
public function getEngine(): iDatabaseEngine;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method invoked by FuzeWorks\Database to setup this tableModel.
|
|
|
|
*
|
|
|
|
* Provides the TableModel with the appropriate iDatabaseEngine and the name of the table.
|
|
|
|
*
|
|
|
|
* @param iDatabaseEngine $engine
|
|
|
|
* @param string $tableName
|
2022-12-22 09:46:13 +00:00
|
|
|
* @return void
|
|
|
|
* @throws DatabaseException
|
2019-09-08 18:32:42 +00:00
|
|
|
*/
|
2022-12-22 09:46:13 +00:00
|
|
|
public function setUp(iDatabaseEngine $engine, string $tableName): void;
|
2019-08-21 14:42:47 +00:00
|
|
|
|
2019-09-08 18:32:42 +00:00
|
|
|
/**
|
|
|
|
* Returns whether the TableModel has been setup yet
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2019-08-21 14:42:47 +00:00
|
|
|
public function isSetup(): bool;
|
|
|
|
|
2019-07-22 09:43:01 +00:00
|
|
|
/**
|
2019-09-08 18:32:42 +00:00
|
|
|
* Creates data in the model.
|
|
|
|
*
|
2019-07-22 09:43:01 +00:00
|
|
|
* @param array $data
|
|
|
|
* @param array $options
|
|
|
|
* @return int
|
|
|
|
* @throws DatabaseException
|
|
|
|
*/
|
2019-09-08 18:32:42 +00:00
|
|
|
public function create(array $data, array $options = []): int;
|
2019-07-22 09:43:01 +00:00
|
|
|
|
|
|
|
/**
|
2019-09-08 18:32:42 +00:00
|
|
|
* Returns data from the model in the form of a TableModelResult
|
|
|
|
*
|
2019-07-22 09:43:01 +00:00
|
|
|
* @param array $filter
|
|
|
|
* @param array $options
|
2019-09-08 18:32:42 +00:00
|
|
|
* @return TableModelResult
|
2019-07-22 09:43:01 +00:00
|
|
|
* @throws DatabaseException
|
2019-09-08 18:32:42 +00:00
|
|
|
* @see TableModelResult
|
2019-07-22 09:43:01 +00:00
|
|
|
*/
|
2019-09-08 18:32:42 +00:00
|
|
|
public function read(array $filter = [], array $options = []): TableModelResult;
|
2019-07-22 09:43:01 +00:00
|
|
|
|
|
|
|
/**
|
2019-09-08 18:32:42 +00:00
|
|
|
* Updates data in the model
|
|
|
|
*
|
2019-07-22 09:43:01 +00:00
|
|
|
* @param array $data
|
|
|
|
* @param array $filter
|
|
|
|
* @param array $options
|
|
|
|
* @return int
|
|
|
|
* @throws DatabaseException
|
|
|
|
*/
|
2019-09-08 18:32:42 +00:00
|
|
|
public function update(array $data, array $filter, array $options = []): int;
|
2019-07-22 09:43:01 +00:00
|
|
|
|
|
|
|
/**
|
2019-09-08 18:32:42 +00:00
|
|
|
* Deletes data from the model
|
|
|
|
*
|
2019-07-22 09:43:01 +00:00
|
|
|
* @param array $filter
|
|
|
|
* @param array $options
|
|
|
|
* @return int
|
|
|
|
* @throws DatabaseException
|
|
|
|
*/
|
2019-09-08 18:32:42 +00:00
|
|
|
public function delete(array $filter, array $options = []): int;
|
2019-07-22 09:43:01 +00:00
|
|
|
|
|
|
|
/**
|
2019-09-08 18:32:42 +00:00
|
|
|
* Starts a transaction in the model when supported
|
|
|
|
*
|
2019-07-22 09:43:01 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function transactionStart(): bool;
|
|
|
|
|
|
|
|
/**
|
2019-09-08 18:32:42 +00:00
|
|
|
* Ends a transaction in the model when supported
|
|
|
|
*
|
2019-07-22 09:43:01 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function transactionEnd(): bool;
|
|
|
|
|
|
|
|
/**
|
2019-09-08 18:32:42 +00:00
|
|
|
* Commits changes in the model when supported
|
|
|
|
*
|
2019-07-22 09:43:01 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function transactionCommit(): bool;
|
|
|
|
|
|
|
|
/**
|
2019-09-08 18:32:42 +00:00
|
|
|
* Rolls back changes in the modle when supported
|
|
|
|
*
|
2019-07-22 09:43:01 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function transactionRollback(): bool;
|
2019-02-26 19:46:33 +00:00
|
|
|
}
|