summaryrefslogtreecommitdiff
path: root/framework/Wsat/TWsatARGenerator.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Wsat/TWsatARGenerator.php')
-rw-r--r--framework/Wsat/TWsatARGenerator.php33
1 files changed, 26 insertions, 7 deletions
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 @@
<?php
/**
- * Description of TWsatARGenerator
- *
- * @author Daniel
+ * @author Daniel Sampedro Bello <darthdaniel85@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2013 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @since 3.3
+ * @package Wsat
*/
class TWsatARGenerator {
@@ -30,10 +34,21 @@ 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;
+ }
+
//-----------------------------------------------------------------------------
// <editor-fold defaultstate="collapsed" desc="Main APIs">
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;
}
}