2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Holds the TableProperty class
6 * @package PhpMyAdmin-Export
9 if (! defined('PHPMYADMIN')) {
16 * @package PhpMyAdmin-Export
36 * Wheter the key is nullable or not
66 * @param array $row table row
70 function __construct($row)
72 $this->name
= trim($row[0]);
73 $this->type
= trim($row[1]);
74 $this->nullable
= trim($row[2]);
75 $this->key
= trim($row[3]);
76 $this->defaultValue
= trim($row[4]);
77 $this->ext
= trim($row[5]);
85 function getPureType()
87 $pos = strpos($this->type
, "(");
89 return substr($this->type
, 0, $pos);
95 * Tells whether the key is null or not
97 * @return bool true if the key is not null, false otherwise
101 return $this->nullable
== "NO" ?
"true" : "false";
105 * Tells whether the key is unique or not
107 * @return bool true if the key is unique, false otherwise
111 return $this->key
== "PRI" ||
$this->key
== "UNI" ?
"true" : "false";
115 * Gets the .NET primitive type
117 * @return string type
119 function getDotNetPrimitiveType()
121 if (strpos($this->type
, "int") === 0) {
124 if (strpos($this->type
, "long") === 0) {
127 if (strpos($this->type
, "char") === 0) {
130 if (strpos($this->type
, "varchar") === 0) {
133 if (strpos($this->type
, "text") === 0) {
136 if (strpos($this->type
, "longtext") === 0) {
139 if (strpos($this->type
, "tinyint") === 0) {
142 if (strpos($this->type
, "datetime") === 0) {
149 * Gets the .NET object type
151 * @return string type
153 function getDotNetObjectType()
155 if (strpos($this->type
, "int") === 0) {
158 if (strpos($this->type
, "long") === 0) {
161 if (strpos($this->type
, "char") === 0) {
164 if (strpos($this->type
, "varchar") === 0) {
167 if (strpos($this->type
, "text") === 0) {
170 if (strpos($this->type
, "longtext") === 0) {
173 if (strpos($this->type
, "tinyint") === 0) {
176 if (strpos($this->type
, "datetime") === 0) {
183 * Gets the index name
185 * @return string containing the name of the index
187 function getIndexName()
189 if (strlen($this->key
) > 0) {
191 . htmlspecialchars($this->name
, ENT_COMPAT
, 'UTF-8')
198 * Tells whether the key is primary or not
200 * @return bool true if the key is primary, false otherwise
204 return $this->key
=="PRI";
208 * Formats a string for C#
210 * @param string $text string to be formatted
212 * @return string formatted text
214 function formatCs($text)
218 ExportCodegen
::cgMakeIdentifier($this->name
, false),
221 return $this->format($text);
225 * Formats a string for XML
227 * @param string $text string to be formatted
229 * @return string formatted text
231 function formatXml($text)
235 htmlspecialchars($this->name
, ENT_COMPAT
, 'UTF-8'),
240 $this->getIndexName(),
243 return $this->format($text);
249 * @param string $text string to be formatted
251 * @return string formatted text
253 function format($text)
257 ExportCodegen
::cgMakeIdentifier($this->name
),
261 "#dotNetPrimitiveType#",
262 $this->getDotNetPrimitiveType(),
266 "#dotNetObjectType#",
267 $this->getDotNetObjectType(),
272 $this->getPureType(),