1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (http://nette.org)
5: *
6: * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
7: *
8: * For the full copyright and license information, please view
9: * the file license.txt that was distributed with this source code.
10: */
11:
12: namespace Nette\Database;
13:
14: use Nette;
15:
16:
17: /**
18: * Information about tables and columns structure.
19: */
20: interface IReflection
21: {
22: const
23: FIELD_TEXT = 'string',
24: FIELD_BINARY = 'bin',
25: FIELD_BOOL = 'bool',
26: FIELD_INTEGER = 'int',
27: FIELD_FLOAT = 'float',
28: FIELD_DATE = 'date',
29: FIELD_TIME = 'time',
30: FIELD_DATETIME = 'datetime';
31:
32: /**
33: * Gets primary key of $table.
34: * @param string
35: * @return string
36: */
37: function getPrimary($table);
38:
39: /**
40: * Gets referenced table & referenced column.
41: * Example:
42: * author, book returns array(book, author_id)
43: *
44: * @param string source table
45: * @param string referencing key
46: * @return array array(referenced table, referenced column)
47: * @throws Reflection\MissingReferenceException
48: * @throws Reflection\AmbiguousReferenceKeyException
49: */
50: function getHasManyReference($table, $key);
51:
52: /**
53: * Gets referenced table & referencing column.
54: * Example
55: * book, author returns array(author, author_id)
56: * book, translator returns array(author, translator_id)
57: *
58: * @param string source table
59: * @param string referencing key
60: * @return array array(referenced table, referencing column)
61: * @throws Reflection\MissingReferenceException
62: */
63: function getBelongsToReference($table, $key);
64:
65: /**
66: * Injects database connection.
67: */
68: function setConnection(Connection $connection);
69:
70: }
71: