Greetings,
I found that you don't have Postgre support in your module.
I would like to provide you the following patch for hook_install. I did the following:
1. PostgreSQL support
2. More accurate types used for MySQL script (in accordance with types used in core tables)
function favorite_nodes_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$result = db_query("CREATE TABLE favorite_nodes (
nid int(10) unsigned NOT NULL,
uid int(10) unsigned NOT NULL,
last int(11) NOT NULL,
PRIMARY KEY (nid, uid)
) Type=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;
");
break;
case 'pgsql':
$result = db_query("CREATE TABLE favorite_nodes (
nid integer NOT NULL,
uid integer NOT NULL,
last integer NOT NULL,
PRIMARY KEY (nid, uid)
);
");
break;
}
if ($result) {
drupal_set_message(t("favourite_nodes module database tables created successfully."));
} else {
drupal_set_message(t("favourite_nodes module database table creation failure. Please view the favourite_nodes module folder and read the README.txt"), 'error');
}
}
Thank you.
Comments
Comment #1
zig007 commentedHi,
I used this install script instead of the original, and it worked perfectly.
However, it made another bug in the module surface. In one(or was it two?) place(s), this SQL is used:
"SELECT COUNT(*) FROM node n INNER JOIN favorite_nodes f ON n.nid = f.nid WHERE n.type = 'resource' AND f.uid = 1 ORDER by f.last DESC"
I am not sure if its allowed to do this in MySQL, but in PgSQL (and all other SQL server variants i have worked with) it is not allowed to use "ORDER BY" within a single count like that(since it has no point whatsoever).
I just tried removing the "ORDER BY"part, but for some reason Drupal has not yet understood this. I'll be back when it does.
Attached a file with my SQL changes in it. Haven't tried, but it should work in MySQL aswell.
Oh, and this was with regards to the 5.x version.
Comment #2
jaydub commentedFollowing up on this issue, I've provided patches for the 5.x
version of favorite_nodes.install and both 5.x and 6.x versions
of favorite_nodes.modules to enable fully functional PostgreSQL
support.
The changes to favorite_nodes.module fix the issue mentioned
in #2 of this issue regarding the ORDER BY clause and problems
with the COUNT queries generated by pager_query. Adding an explicit
count query to be used in the pager_query call solves the problem.
Comment #3
kbahey commentedThanks.
Committed to 5.x-1.x-dev, and 6.x-1.x-dev.
P.S. Patches that span files should be in one patch file. So, for the above, the 5.x patch for the .module and .install should be one patch.
See http://drupal.org/patch for more details.
Comment #4
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.