Improved the table detection in the mapping of the extrusion class when building table/fields from mysql dump

This commit is contained in:
Llewellyn van der Merwe 2018-06-15 15:31:23 +02:00
parent 3db9deb534
commit 0c7d7265dd
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
5 changed files with 31 additions and 16 deletions

View File

@ -125,7 +125,7 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 13th June, 2018 + *Last Build*: 15th June, 2018
+ *Version*: 2.8.0 + *Version*: 2.8.0
+ *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -125,7 +125,7 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 13th June, 2018 + *Last Build*: 15th June, 2018
+ *Version*: 2.8.0 + *Version*: 2.8.0
+ *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt

View File

@ -1417,6 +1417,11 @@ class Interpretation extends Fields
$method[] = $this->_t(3) . "'password1' => \$password, // First password field"; $method[] = $this->_t(3) . "'password1' => \$password, // First password field";
$method[] = $this->_t(3) . "'password2' => \$password2, // Confirm password field"; $method[] = $this->_t(3) . "'password2' => \$password2, // Confirm password field";
$method[] = $this->_t(3) . "'block' => 0 );"; $method[] = $this->_t(3) . "'block' => 0 );";
$method[] = $this->_t(2) . "// set groups if found";
$method[] = $this->_t(2) . "if (isset(\$new['groups']) && self::checkArray(\$new['groups']))";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "\$data['groups'] = \$new['groups'];";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "// register the new user"; $method[] = $this->_t(2) . "// register the new user";
$method[] = $this->_t(2) . "\$done = \$model->save(\$data);"; $method[] = $this->_t(2) . "\$done = \$model->save(\$data);";
$method[] = $this->_t(2) . "// if user is updated"; $method[] = $this->_t(2) . "// if user is updated";

View File

@ -101,7 +101,7 @@ class Mapping
{ {
// set the app to insure messages can be set // set the app to insure messages can be set
$this->app = JFactory::getApplication(); $this->app = JFactory::getApplication();
if (ComponentbuilderHelper::checkArray($data)) if (ComponentbuilderHelper::checkArray($data))
{ {
if (isset($data['buildcomp']) && 1 == $data['buildcomp'] && isset($data['buildcompsql'])) if (isset($data['buildcomp']) && 1 == $data['buildcomp'] && isset($data['buildcompsql']))
@ -155,7 +155,7 @@ class Mapping
); );
return false; return false;
} }
/** /**
* The mapping function * The mapping function
* To Map the views and fields that are needed * To Map the views and fields that are needed
@ -169,7 +169,8 @@ class Mapping
foreach ($queries as $query) foreach ($queries as $query)
{ {
// only use create table queries // only use create table queries
if (strpos($query, 'CREATE TABLE IF NOT EXISTS `') !== false) if (strpos($query, 'CREATE TABLE IF NOT EXISTS') !== false ||
strpos($query, 'CREATE TABLE') !== false)
{ {
if ($tableName = $this->getTableName($query)) if ($tableName = $this->getTableName($query))
{ {
@ -205,15 +206,24 @@ class Mapping
} }
return false; return false;
} }
/** /**
* Get the table name * Get the table name
*/ */
protected function getTableName(&$query) protected function getTableName(&$query)
{ {
$tableName = ComponentbuilderHelper::getBetween($query, '`#__', "`"); if (strpos($query, '`#__') !== false)
{
// get table name
$tableName = ComponentbuilderHelper::getBetween($query, '`#__', "`");
}
elseif (strpos($query, "'#__") !== false)
{
// get table name
$tableName = ComponentbuilderHelper::getBetween($query, "'#__", "'");
}
// if it still was not found // if it still was not found
if (!ComponentbuilderHelper::checkString($tableName)) if (!isset($tableName) || !ComponentbuilderHelper::checkString($tableName))
{ {
// skip this query // skip this query
return false; return false;
@ -231,13 +241,13 @@ class Mapping
// skip this query // skip this query
return false; return false;
} }
/** /**
* Get the field details * Get the field details
*/ */
protected function getFields(&$query) protected function getFields(&$query)
{ {
$rows = array_map('trim', explode("\n", $query)); $rows = array_map('trim', explode(PHP_EOL, $query));
$fields = array(); $fields = array();
foreach ($rows as $row) foreach ($rows as $row)
{ {
@ -306,7 +316,7 @@ class Mapping
} }
return false; return false;
} }
/** /**
* Get the field types * Get the field types
*/ */
@ -325,7 +335,7 @@ class Mapping
} }
return false; return false;
} }
/** /**
* Get the field size * Get the field size
*/ */
@ -337,7 +347,7 @@ class Mapping
} }
return ''; return '';
} }
/** /**
* Get the field default * Get the field default
*/ */
@ -355,7 +365,7 @@ class Mapping
} }
return ''; return '';
} }
/** /**
* Get the field Null Value * Get the field Null Value
*/ */
@ -373,7 +383,7 @@ class Mapping
} }
return 'NULL'; return 'NULL';
} }
/** /**
* Get the field key status * Get the field key status
*/ */

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade"> <extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name> <name>COM_COMPONENTBUILDER</name>
<creationDate>13th June, 2018</creationDate> <creationDate>15th June, 2018</creationDate>
<author>Llewellyn van der Merwe</author> <author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail> <authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl> <authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>