1: <?php
2:
3: namespace Alchemy\core\schema;
4: use Alchemy\core\Element;
5:
6:
7: 8: 9:
10: abstract class TableElement extends Element {
11:
12: protected $args;
13: protected $table;
14: protected $name;
15:
16:
17: 18: 19: 20: 21:
22: public function __construct($type, $args = array(), $table = null, $name = '') {
23: parent::__construct($type);
24:
25: $this->name = $name;
26: $this->table = $table;
27: $def = static::get_definition($this->type);
28: $this->args = self::normalize_arg($args, $def['defaults']);
29:
30: $parts = explode('\\', get_called_class());
31: $cls = array_pop($parts);
32: $this->addTag("sql.create", $cls);
33: }
34:
35:
36: 37: 38: 39: 40:
41: public function copy(array $args = array(), $table = null, $name = '') {
42: return new static($this->type, $args + $this->args, $table, $name);
43: }
44:
45:
46: public function getName() {
47: return $this->name ?: "";
48: }
49:
50:
51: public function getTable() {
52: return $this->table;
53: }
54: }