File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,22 @@ public function tableExists() {
4343 return $ this ->database ->tableExists ($ this ->tableName );
4444 }
4545
46+ /**
47+ * Describes the underlying table.
48+ * {
49+ * "Field": "uid",
50+ * "Type": "int(10) unsigned",
51+ * "Null": "NO",
52+ * "Key": "PRI",
53+ * "Default": null,
54+ * "Extra": "auto_increment"
55+ * }
56+ * @return array of columns (empty when error occured).
57+ */
58+ public function describeTable () {
59+ return $ this ->database ->describeTable ($ this ->tableName );
60+ }
61+
4662 /**
4763 * Get the object with given id.
4864 * @param int $uid - ID of object (row)
Original file line number Diff line number Diff line change @@ -100,12 +100,33 @@ public function quoteName($s) {
100100 * @return string TRUE when table exists, FALSE otherwise.
101101 */
102102 public function tableExists ($ tableName ) {
103- $ res = $ this ->query ('SELECT * FROM ' .$ this -> tableName );
103+ $ res = $ this ->query ('SELECT * FROM ' .$ tableName );
104104 $ rc = $ res !== FALSE ;
105105 if ($ res ) $ res ->free ();
106106 return $ rc ;
107107 }
108108
109+ /**
110+ * Describes a table.
111+ * {
112+ * "Field": "uid",
113+ * "Type": "int(10) unsigned",
114+ * "Null": "NO",
115+ * "Key": "PRI",
116+ * "Default": null,
117+ * "Extra": "auto_increment"
118+ * }
119+ * @param string $tableName - name of table to be described
120+ * @return array of columns (empty when error occured).
121+ */
122+ public function describeTable ($ tableName ) {
123+ $ rc = array ();
124+ foreach ($ this ->queryList ('DESCRIBE ' .$ tableName ) AS $ field ) {
125+ $ rc [$ field ->Field ] = $ field ;
126+ }
127+ return $ rc ;
128+ }
129+
109130 /**
110131 * Execute the given SQL.
111132 * <p>This can be any arbitrary SQL statement. The function will only replace the table prefix
You can’t perform that action at this time.
0 commit comments