meraproject/module/core/db/structure/table.php

64 lines
1.4 KiB
PHP
Raw Permalink Normal View History

<?
class Table {
const NAME = 1;
const COLUMNS = 2;
const COLUMNS_PREFIX = 3;
private $name = '';
private $columns = [];
private $columns_prefix = '';
//-------------------------------
// MAGIC FUNCTIONS
//-------------------------------
function __construct(array $options) {
$this->setName( $options[self::NAME] );
$this->setColumns( $options[self::COLUMNS] );
$this->setColumnsPrefix( $options[self::COLUMNS_PREFIX] );
}
function insert($values){
Query::insert($this,$values);
}
function create(){
echo Query::createTable($this);
}
function columnNames(){
return array_keys($this->columns);
}
//-------------------------------
// SETTERS AND GETTERS
//-------------------------------
/**
* @return columnInfo
*/
public function getColumns(): array { return $this->columns; }
/**
* @param array $columns
*/
public function setColumns(array $columns) { $this->columns = $columns; }
/**
* @return string
*/
public function getName(): string { return $this->name; }
/**
* @param string $name
*/
public function setName(string $name) { $this->name = trim((string)$name); }
public function getColumnsPrefix() { return $this->columns_prefix ; }
public function setColumnsPrefix(string $prefix) { $this->columns_prefix = trim((string)$prefix); }
}