diff options
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | framework/Data/ActiveRecord/TActiveRecordGateway.php | 10 | ||||
-rwxr-xr-x | framework/prado-cli.php | 38 |
3 files changed, 27 insertions, 22 deletions
@@ -24,6 +24,7 @@ ENH: Ticket#893 - Added page parameter to queryForPagedList() to specify the ini ENH: Ticket#896 - TTheme - enhance for subclassing (Knut) ENH: Ticket#898 - Minor optimization: Use (int) over intval() (Knut) ENH: Ticket#901 - Using TDbDataReader directly as a DataSource of TDataBoundControl's like TDataGrid (Knut) +ENH: Ticket#911 - prado-cli: Better error message if database connection fails when generating Active Record skeletons (Knut) CHG: Ticket#844 - Upgraded TinyMCE to 3.1.0.1 (Christophe) Version 3.1.2 April 21, 2008 diff --git a/framework/Data/ActiveRecord/TActiveRecordGateway.php b/framework/Data/ActiveRecord/TActiveRecordGateway.php index b31cde5e..23104c00 100644 --- a/framework/Data/ActiveRecord/TActiveRecordGateway.php +++ b/framework/Data/ActiveRecord/TActiveRecordGateway.php @@ -1,10 +1,10 @@ -<?php +<?php
/**
* TActiveRecordGateway, TActiveRecordStatementType, TActiveRecordEventParameter classes file.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Data.ActiveRecord
@@ -87,7 +87,7 @@ class TActiveRecordGateway extends TComponent * @param string table name
* @return TDbTableInfo table details.
*/
- public function getTableInfo($connection, $tableName)
+ public function getTableInfo(TDbConnection $connection, $tableName)
{
$connStr = $connection->getConnectionString();
$key = $connStr.$tableName;
@@ -410,5 +410,5 @@ class TActiveRecordGateway extends TComponent $record->{$event}($param);
}
}
- -?> +
+?>
diff --git a/framework/prado-cli.php b/framework/prado-cli.php index 1c54c75f..9b9153c3 100755 --- a/framework/prado-cli.php +++ b/framework/prado-cli.php @@ -661,24 +661,28 @@ class PradoCommandLineActiveRecordGen extends PradoCommandLineAction protected function generateActiveRecord($config, $tablename, $output) { $manager = TActiveRecordManager::getInstance(); - $gateway = $manager->getRecordGateway(); - $tableInfo = $gateway->getTableInfo($manager->getDbConnection(), $tablename); - if(count($tableInfo->getColumns()) === 0) - { - echo '** Unable to find table or view "'.$tablename.'" in "'.$manager->getDbConnection()->getConnectionString()."\".\n"; - return false; - } - else - { - $properties = array(); - foreach($tableInfo->getColumns() as $field=>$column) - $properties[] = $this->generateProperty($field,$column); - } + if($connection = $manager->getDbConnection()) { + $gateway = $manager->getRecordGateway(); + $tableInfo = $gateway->getTableInfo($manager->getDbConnection(), $tablename); + if(count($tableInfo->getColumns()) === 0) + { + echo '** Unable to find table or view "'.$tablename.'" in "'.$manager->getDbConnection()->getConnectionString()."\".\n"; + return false; + } + else + { + $properties = array(); + foreach($tableInfo->getColumns() as $field=>$column) + $properties[] = $this->generateProperty($field,$column); + } - $classname = basename($output, '.php'); - $class = $this->generateClass($properties, $tablename, $classname); - echo " Writing class $classname to file $output\n"; - file_put_contents($output, $class); + $classname = basename($output, '.php'); + $class = $this->generateClass($properties, $tablename, $classname); + echo " Writing class $classname to file $output\n"; + file_put_contents($output, $class); + } else { + echo '** Unable to connect to database with ConnectionID=\''.$config->getConnectionID()."'. Please check your settings in application.xml and ensure your database connection is set up first.\n"; + } } protected function generateProperty($field,$column) |