I edited the cake/libs/model/dbo/dbo_postgres.php in versions 1.1.5 and
1.1.8 of Cake in the following manner:
Change this line:
$sql = "SELECT table_name as name FROM INFORMATION_SCHEMA.tables WHERE
table_schema = 'public';";
To this:
$sql = "SELECT table_schema ||'.'|| table_name as name FROM
INFORMATION_SCHEMA.tables;";
And where you see:
$cols = $this->fetchAll("SELECT DISTINCT column_name AS name, data_type
AS type, is_nullable AS null, column_default AS default,
ordinal_position FROM information_schema.columns WHERE table_name =" .
$this->value($model->tablePrefix . $model->table) . " ORDER BY
ordinal_position");
in function &describe(&$model) change it to this:
$schemaSupport = strpos($this->value($model->table), ".");
if ($schemaSupport !== false ) {
$tableSchema =
substr($this->value($model->table),0,$schemaSupport);
$tableName =
substr($this->value($model->table),$schemaSupport+1);
$cols = $this->fetchAll("SELECT DISTINCT column_name AS
name,
data_type AS type, is_nullable AS null, column_default AS default,
ordinal_position FROM information_schema.columns WHERE table_name
='$tableName and table_schema=$tableSchema' ORDER BY
ordinal_position");
}
else {
$cols = $this->fetchAll("SELECT DISTINCT column_name AS
name,
data_type AS type, is_nullable AS null, column_default AS default,
ordinal_position FROM information_schema.columns WHERE table_name =" .
$this->value($model->tablePrefix . $model->table) . " AND
table_schema='public' ORDER BY ordinal_position");
}
The last thing you have to do is specify:
var $useTable = 'schema.tablename';
in your Models For example:
class Billing extends AppModel {
var $name = 'Billing';
var $useTable = 'billing.stuff';
}
I've only been using Cake for a couple months now, so I don't know if
this is *the* solution, but it has worked well for the time I have been
using it. I use PostgreSQL 8 with a lot of 'legacy'-named tables
(which, at this point, has persuaded me to use raw SQL instead some of
the nicer Cake table constructs).
Hope this is useful.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---