From 227ef973f923ec201a1ece197f6242b3248c66ae Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 25 Nov 2013 12:49:07 -0500 Subject: WSAT beta release with doc. --- framework/Wsat/TWsatARGenerator.php | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'framework/Wsat/TWsatARGenerator.php') diff --git a/framework/Wsat/TWsatARGenerator.php b/framework/Wsat/TWsatARGenerator.php index 433e1640..ed873358 100644 --- a/framework/Wsat/TWsatARGenerator.php +++ b/framework/Wsat/TWsatARGenerator.php @@ -1,9 +1,13 @@ + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2013 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @since 3.3 + * @package Wsat */ class TWsatARGenerator { @@ -29,11 +33,22 @@ class TWsatARGenerator { */ private $_clas_prefix; + /** + * Class name sufix + */ + private $_class_sufix; + /** * all table relations array */ private $_relations; + /** + * unquote chars + * @var array + */ + private $uq_chars = array('[', ']', '"', '`', "'"); + function __construct() { $ar_manager = TActiveRecordManager::getInstance(); $this->_conn = $ar_manager->getDbConnection(); @@ -65,6 +80,10 @@ class TWsatARGenerator { $this->_clas_prefix = $_clas_prefix; } + public function setClassSufix($_clas_sufix) { + $this->_class_sufix = $_clas_sufix; + } + //----------------------------------------------------------------------------- // public function generate($tableName) { @@ -137,7 +156,7 @@ class TWsatARGenerator { private function _getProperClassName($tableName) { $table_name_words = str_replace("_", " ", strtolower($tableName)); $final_conversion = str_replace(" ", "", ucwords($table_name_words)); - return $this->_clas_prefix . $final_conversion; + return $this->_clas_prefix . $final_conversion . $this->_class_sufix; } public function renderAllTablesInformation() { @@ -184,9 +203,9 @@ class TWsatARGenerator { try { foreach ($tableInfo->getColumns() as $column) { if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) { - $property = str_replace(array("`", "'", '"'), "", $column->ColumnName); - } elseif ($column->DbType == "varchar") { - $property = str_replace(array("`", "'", '"'), "", $column->ColumnName); + $property = str_replace($this->uq_chars, "", $column->ColumnName); + } elseif ($column->PHPType == "string" && $column->DBType != "date") { + $property = str_replace($this->uq_chars, "", $column->ColumnName); break; } } -- cgit v1.2.3