Overview

Namespaces

  • Alchemy
    • core
      • query
      • schema
    • dialect
    • engine
    • orm
    • tests
    • util
      • promise
  • PHP

Classes

  • Column
  • Foreign
  • ForeignKey
  • Index
  • Table
  • TableElement
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace Alchemy\core\schema;
 4: use Alchemy\core\Element;
 5: 
 6: 
 7: /**
 8:  * Class for representing an index in SQL
 9:  */
10: abstract class TableElement extends Element {
11: 
12:     protected $args;
13:     protected $table;
14:     protected $name;
15: 
16: 
17:     /**
18:      * Object Constructor
19:      *
20:      * @param array $args
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:      * Duplicates this, but possibly as a different class
38:      *
39:      * @return TableElement
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: }
API documentation generated by ApiGen 2.8.0