Jump to content
TNG Community

Backing out code with the UNION command for MySQL 3x


Darrin Lythgoe

Recommended Posts

Darrin Lythgoe

If you're using 6.1.1 along with a version of MySQL prior to MySQL 4 and you're seeing SQL errors that contain the MySQL "UNION", then you have three choices:

A. You can upgrade your MySQL to at least v4 (or ask your hosting provider to do it).

B. Switch to a hosting provider that does support MySQL 4 or 5 (a bit drastic, I know).

C. Back the code out. You will not be able to take advantage of the faster queries produced by this new code, but it will function. Here are the things you'll need to change (please pardon any wrapping that may occur):

1. timeline2.php, line 107, replace this line:

$query = "SELECT husband, wife, familyID, living, branch, marrdate, marrdatetr, IF(marrdatetr !='0000-00-00',YEAR(marrdatetr),YEAR(marrdatetr)) as marriage FROM $families_table WHERE $families_table.husband = \"$personID\" AND gedcom = \"$tree\" UNION SELECT husband, wife, familyID, living, branch, marrdate, marrdatetr, IF(marrdatetr !='0000-00-00',YEAR(marrdatetr),YEAR(marrdatetr)) as marriage FROM $families_table WHERE $families_table.wife = \"$personID\" AND gedcom = \"$tree\"";

with this one from the same file in v6.1.0:

$query = "SELECT husband, wife, familyID, living, branch, marrdate, marrdatetr, IF(marrdatetr !='0000-00-00',YEAR(marrdatetr),YEAR(marrdatetr)) as marriage FROM $families_table WHERE ($families_table.husband = \"$personID\" OR $families_table.wife = \"$personID\") AND gedcom = \"$tree\"";

2. reglib.php, line 23, replace this line:

$query = "SELECT husband, wife, familyID, marrdate, marrplace, marrtype, living, branch FROM $families_table WHERE $families_table.wife = \"$personID\" AND gedcom = \"$tree\" UNION SELECT husband, wife, familyID, marrdate, marrplace, marrtype, living, branch FROM $families_table WHERE $families_table.husband = \"$personID\" AND gedcom = \"$tree\"";

with this one from the same file in 6.1.0:

$query = "SELECT husband, wife, familyID, marrdate, marrplace, marrtype, living, branch FROM $families_table WHERE ($families_table.wife = \"$personID\" OR $families_table.husband = \"$personID\") AND gedcom = \"$tree\"";

3. reglib.php, line 27, replace this line:

$query = "SELECT husband, wife, familyID, marrdate, marrplace, marrtype, living, branch FROM $families_table WHERE $families_table.wife = \"$personID\" AND gedcom = \"$tree\" UNION SELECT husband, wife, familyID, marrdate, marrplace, marrtype, living, branch FROM $families_table WHERE $families_table.husband = \"$personID\" AND gedcom = \"$tree\"";

with this one from the same file in 6.1.0:

$query = "SELECT husband, wife, familyID, marrdate, marrplace, marrtype, living, branch FROM $families_table WHERE ($families_table.wife = \"$personID\" OR $families_table.husband = \"$personID\") AND gedcom = \"$tree\"";

4. placesearch.php: The changes are too complicated to back out like this. Just replace the file with the 6.1.0 version.

5. getperson.php, line 273, replace this line:

$query = "SELECT husband, wife, familyID, living, branch, marrdate, marrdatetr, marrplace, marrtype, divdate, divdatetr, divplace, sealdate, sealdatetr, sealplace, DATE_FORMAT(changedate,\"%d %b %Y %H:%i:%s\") as changedate FROM $families_table WHERE $families_table.husband = \"$personID\" AND gedcom = \"$tree\" UNION SELECT husband, wife, familyID, living, branch, marrdate, marrdatetr, marrplace, marrtype, divdate, divdatetr, divplace, sealdate, sealdatetr, sealplace, DATE_FORMAT(changedate,\"%d %b %Y %H:%i:%s\") as changedate FROM $families_table WHERE $families_table.wife = \"$personID\" AND gedcom = \"$tree\"";

with this one from the same file in 6.1.0:

$query = "SELECT husband, wife, familyID, living, branch, marrdate, marrdatetr, marrplace, marrtype, divdate, divdatetr, divplace, sealdate, sealdatetr, sealplace, DATE_FORMAT(changedate,\"%d %b %Y %H:%i:%s\") as changedate FROM $families_table WHERE ($families_table.husband = \"$personID\" OR $families_table.wife = \"$personID\") AND gedcom = \"$tree\"";

6. getperson.php, line 277, replace this line:

$query = "SELECT husband, wife, familyID, living, branch, marrdate, marrdatetr, marrplace, marrtype, divdate, divdatetr, divplace, sealdate, sealdatetr, sealplace, DATE_FORMAT(changedate,\"%d %b %Y\") as changedate FROM $families_table WHERE $families_table.husband = \"$personID\" AND gedcom = \"$tree\" UNION SELECT husband, wife, familyID, living, branch, marrdate, marrdatetr, marrplace, marrtype, divdate, divdatetr, divplace, sealdate, sealdatetr, sealplace, DATE_FORMAT(changedate,\"%d %b %Y\") as changedate FROM $families_table WHERE $families_table.wife = \"$personID\" AND gedcom = \"$tree\"";

with this one from the same file in 6.1.0:

$query = "SELECT husband, wife, familyID, living, branch, marrdate, marrdatetr, marrplace, marrtype, divdate, divdatetr, divplace, sealdate, sealdatetr, sealplace, DATE_FORMAT(changedate,\"%d %b %Y\") as changedate FROM $families_table WHERE ($families_table.husband = \"$personID\" OR $families_table.wife = \"$personID\") AND gedcom = \"$tree\"";

7. gedcom.php, line 660, replace this line:

$query = "SELECT * FROM $families_table WHERE husband = \"$person\" AND gedcom = \"$tree\" UNION SELECT * FROM $families_table WHERE wife = \"$person\" AND gedcom = \"$tree\"";

with this one from the same file in 6.1.0:

$query = "SELECT * FROM $families_table WHERE (husband = \"$person\" OR wife = \"$person\") AND gedcom = \"$tree\"";

8. descendtext.php, line 50, replace this line:

$query = "SELECT husband, wife, familyID FROM $families_table WHERE $families_table.wife = \"$key\" AND gedcom = \"$tree\" UNION SELECT husband, wife, familyID FROM $families_table WHERE $families_table.husband = \"$key\" AND gedcom = \"$tree\"";

with this one from the same file in 6.1.0:

$query = "SELECT husband, wife, familyID FROM $families_table WHERE ($families_table.wife = \"$key\" OR $families_table.husband = \"$key\") AND gedcom = \"$tree\"";

9. descendtext.php, line 54, replace this line:

$query = "SELECT husband, wife, familyID FROM $families_table WHERE $families_table.wife = \"$key\" AND gedcom = \"$tree\" UNION SELECT husband, wife, familyID FROM $families_table WHERE $families_table.husband = \"$key\" AND gedcom = \"$tree\"";

with this one from the same file in 6.1.0:

$query = "SELECT husband, wife, familyID FROM $families_table WHERE ($families_table.wife = \"$key\" OR $families_table.husband = \"$key\") AND gedcom = \"$tree\"";

10. descend.php, line 302, replace this line:

$query = "SELECT husband, wife, familyID FROM $families_table WHERE $families_table.wife = \"$person\" AND gedcom = \"$tree\" UNION SELECT husband, wife, familyID FROM $families_table WHERE $families_table.husband = \"$person\" AND gedcom = \"$tree\"";

with this one from the same file in 6.1.0:

$query = "SELECT husband, wife, familyID FROM $families_table WHERE ($families_table.wife = \"$person\" OR $families_table.husband = \"$person\") AND gedcom = \"$tree\"";

Darrin

Link to comment
Share on other sites

  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...