Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Db / Metadata / Metadata.php
blob4ad8016997cf4172b7d57f12338b749261e87eaa
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Db\Metadata;
12 use Zend\Db\Adapter\Adapter;
14 class Metadata implements MetadataInterface
16 /**
17 * Adapter
19 * @var Adapter
21 protected $adapter = null;
23 /**
24 * @var MetadataInterface
26 protected $source = null;
28 /**
29 * Constructor
31 * @param Adapter $adapter
33 public function __construct(Adapter $adapter)
35 $this->adapter = $adapter;
36 $this->source = $this->createSourceFromAdapter($adapter);
39 /**
40 * Create source from adapter
42 * @param Adapter $adapter
43 * @return Source\AbstractSource
45 protected function createSourceFromAdapter(Adapter $adapter)
47 switch ($adapter->getPlatform()->getName()) {
48 case 'MySQL':
49 return new Source\MysqlMetadata($adapter);
50 case 'SQLServer':
51 return new Source\SqlServerMetadata($adapter);
52 case 'SQLite':
53 return new Source\SqliteMetadata($adapter);
54 case 'PostgreSQL':
55 return new Source\PostgresqlMetadata($adapter);
58 throw new \Exception('cannot create source from adapter');
61 // @todo methods
63 /**
64 * Get base tables and views
66 * @param string $schema
67 * @param bool $includeViews
68 * @return Object\TableObject[]
70 public function getTables($schema = null, $includeViews = false)
72 return $this->source->getTables($schema, $includeViews);
75 /**
76 * Get base tables and views
78 * @param string $schema
79 * @return Object\TableObject[]
81 public function getViews($schema = null)
83 return $this->source->getViews($schema);
86 /**
87 * Get triggers
89 * @param string $schema
90 * @return array
92 public function getTriggers($schema = null)
94 return $this->source->getTriggers($schema);
97 /**
98 * Get constraints
100 * @param string $table
101 * @param string $schema
102 * @return array
104 public function getConstraints($table, $schema = null)
106 return $this->source->getConstraints($table, $schema);
110 * Get columns
112 * @param string $table
113 * @param string $schema
114 * @return array
116 public function getColumns($table, $schema = null)
118 return $this->source->getColumns($table, $schema);
122 * Get constraint keys
124 * @param string $constraint
125 * @param string $table
126 * @param string $schema
127 * @return array
129 public function getConstraintKeys($constraint, $table, $schema = null)
131 return $this->source->getConstraintKeys($constraint, $table, $schema);
135 * Get constraints
137 * @param string $constraintName
138 * @param string $table
139 * @param string $schema
140 * @return Object\ConstraintObject
142 public function getConstraint($constraintName, $table, $schema = null)
144 return $this->source->getConstraint($constraintName, $table, $schema);
148 * Get schemas
150 public function getSchemas()
152 return $this->source->getSchemas();
156 * Get table names
158 * @param string $schema
159 * @param bool $includeViews
160 * @return array
162 public function getTableNames($schema = null, $includeViews = false)
164 return $this->source->getTableNames($schema, $includeViews);
168 * Get table
170 * @param string $tableName
171 * @param string $schema
172 * @return Object\TableObject
174 public function getTable($tableName, $schema = null)
176 return $this->source->getTable($tableName, $schema);
180 * Get views names
182 * @param string $schema
183 * @return \Zend\Db\Metadata\Object\TableObject
185 public function getViewNames($schema = null)
187 return $this->source->getTable($schema);
191 * Get view
193 * @param string $viewName
194 * @param string $schema
195 * @return \Zend\Db\Metadata\Object\TableObject
197 public function getView($viewName, $schema = null)
199 return $this->source->getView($viewName, $schema);
203 * Get trigger names
205 * @param string $schema
206 * @return array
208 public function getTriggerNames($schema = null)
210 return $this->source->getTriggerNames($schema);
214 * Get trigger
216 * @param string $triggerName
217 * @param string $schema
218 * @return \Zend\Db\Metadata\Object\TriggerObject
220 public function getTrigger($triggerName, $schema = null)
222 return $this->source->getTrigger($triggerName, $schema);
226 * Get column names
228 * @param string $table
229 * @param string $schema
230 * @return array
232 public function getColumnNames($table, $schema = null)
234 return $this->source->getColumnNames($table, $schema);
238 * Get column
240 * @param string $columnName
241 * @param string $table
242 * @param string $schema
243 * @return \Zend\Db\Metadata\Object\ColumnObject
245 public function getColumn($columnName, $table, $schema = null)
247 return $this->source->getColumn($columnName, $table, $schema);