I have successfully used phpCodeGenie with MySQL (and what an excellent tool it is - thank you!). However, I have tried to use it with Microsoft SQL Server and with ODBC using a local DSN and although the database connection is fine I cant get it to work, because it fails to show the databases, only tables in the default database. The code generator will not allow you to proceed because you "Haven't selected a database" .... very frustrating!
I suspect that the reason for this is that both SQL Server and the ODBC DSN define a default database for the specified login. Does anyone know how to get around this, or if it possible to pre-define the database name to be used in PCG?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I managed to circumvent this problem by modifying app/common/database/databaseQuery.class.php.
If you scroll to the bottom you'll see a function called getDatabases(). If you edit it to look something like this, PCG will allow you to select the database and generate code.
function getDatabases()
{
if (($this->getDatabaseType()=="mysql") || /*($this->getDatabaseType()=="odbc") || */($this->getDatabaseType()=="ado"))
{
return $this->dbConn->MetaDatabases();
}
else
{
// return "";
return array("servers"); // this is a cheap hack to get it working
}
}
I'm still having problems, however. The generated code doesn't know anything about the columns in the tables, only the table names. I suspect there are more routines that make assumptions about what the DB will return for me to find and 'fix'.
This is an ugly hack and I'm not proud of it, but it got me farther along... sigh...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A better is to change the first part of the IF statement to
if (($this->getDatabaseType()=="mysql") || ($this->getDatabaseType()=="odbc") || ($this->getDatabaseType()=="ado") || ($this->getDatabaseType() == "mssqlpo")).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have successfully used phpCodeGenie with MySQL (and what an excellent tool it is - thank you!). However, I have tried to use it with Microsoft SQL Server and with ODBC using a local DSN and although the database connection is fine I cant get it to work, because it fails to show the databases, only tables in the default database. The code generator will not allow you to proceed because you "Haven't selected a database" .... very frustrating!
I suspect that the reason for this is that both SQL Server and the ODBC DSN define a default database for the specified login. Does anyone know how to get around this, or if it possible to pre-define the database name to be used in PCG?
I have the same doubt
I managed to circumvent this problem by modifying app/common/database/databaseQuery.class.php.
If you scroll to the bottom you'll see a function called getDatabases(). If you edit it to look something like this, PCG will allow you to select the database and generate code.
function getDatabases()
{
if (($this->getDatabaseType()=="mysql") || /*($this->getDatabaseType()=="odbc") || */($this->getDatabaseType()=="ado"))
{
return $this->dbConn->MetaDatabases();
}
else
{
// return "";
return array("servers"); // this is a cheap hack to get it working
}
}
I'm still having problems, however. The generated code doesn't know anything about the columns in the tables, only the table names. I suspect there are more routines that make assumptions about what the DB will return for me to find and 'fix'.
This is an ugly hack and I'm not proud of it, but it got me farther along... sigh...
A better is to change the first part of the IF statement to
if (($this->getDatabaseType()=="mysql") || ($this->getDatabaseType()=="odbc") || ($this->getDatabaseType()=="ado") || ($this->getDatabaseType() == "mssqlpo")).