/**
  * Test for PMA\libraries\plugins\export\ExportCodegen::cgMakeIdentifier
  *
  * @return void
  */
 public function testCgMakeIdentifier()
 {
     $this->assertEquals('_Ⅲfoo', ExportCodegen::cgMakeIdentifier('Ⅲ{}96`{}foo', true));
     $this->assertEquals('TestⅢ', ExportCodegen::cgMakeIdentifier('`98testⅢ{}96`{}', true));
     $this->assertEquals('testⅢ', ExportCodegen::cgMakeIdentifier('`98testⅢ{}96`{}', false));
 }
Example #2
0
 /**
  * XML Handler
  *
  * @param string $db      database name
  * @param string $table   table name
  * @param string $crlf    line separator
  * @param array  $aliases Aliases of db/table/columns
  *
  * @return string containing XML code lines, separated by "\n"
  */
 private function _handleNHibernateXMLBody($db, $table, $crlf, $aliases = array())
 {
     $db_alias = $db;
     $table_alias = $table;
     $this->initAlias($aliases, $db_alias, $table_alias);
     $lines = array();
     $lines[] = '<?xml version="1.0" encoding="utf-8" ?' . '>';
     $lines[] = '<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" ' . 'namespace="' . ExportCodegen::cgMakeIdentifier($db_alias) . '" ' . 'assembly="' . ExportCodegen::cgMakeIdentifier($db_alias) . '">';
     $lines[] = '    <class ' . 'name="' . ExportCodegen::cgMakeIdentifier($table_alias) . '" ' . 'table="' . ExportCodegen::cgMakeIdentifier($table_alias) . '">';
     $result = $GLOBALS['dbi']->query(sprintf("DESC %s.%s", PMA\libraries\Util::backquote($db), PMA\libraries\Util::backquote($table)));
     if ($result) {
         while ($row = $GLOBALS['dbi']->fetchRow($result)) {
             $col_as = $this->getAlias($aliases, $row[0], 'col', $db, $table);
             if (!empty($col_as)) {
                 $row[0] = $col_as;
             }
             $tableProperty = new TableProperty($row);
             if ($tableProperty->isPK()) {
                 $lines[] = $tableProperty->formatXml('        <id name="#ucfirstName#" type="#dotNetObjectType#"' . ' unsaved-value="0">' . "\n" . '            <column name="#name#" sql-type="#type#"' . ' not-null="#notNull#" unique="#unique#"' . ' index="PRIMARY"/>' . "\n" . '            <generator class="native" />' . "\n" . '        </id>');
             } else {
                 $lines[] = $tableProperty->formatXml('        <property name="#ucfirstName#"' . ' type="#dotNetObjectType#">' . "\n" . '            <column name="#name#" sql-type="#type#"' . ' not-null="#notNull#" #indexName#/>' . "\n" . '        </property>');
             }
         }
         $GLOBALS['dbi']->freeResult($result);
     }
     $lines[] = '    </class>';
     $lines[] = '</hibernate-mapping>';
     return implode($crlf, $lines);
 }