Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column mismatch error #4

Open
oxwilder opened this issue Mar 22, 2023 · 0 comments
Open

Column mismatch error #4

oxwilder opened this issue Mar 22, 2023 · 0 comments

Comments

@oxwilder
Copy link

oxwilder commented Mar 22, 2023

Running make, I received the following error:

PHP Fatal error:  Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'documentID' in 'where clause' in/phriction/phriction-to-github-wiki/includes/class.phabricatorexport.php:32
Stack trace:
#0 /phriction/phriction-to-github-wiki/includes/class.phabricatorexport.php(32): PDO->query()
#1 /phriction/phriction-to-github-wiki/includes/class.phabricatorexport.php(25): PhabricatorExport->getDocument()
#2 /phriction/phriction-to-github-wiki/run.php(8): PhabricatorExport->getDocumentIndex()
#3 {main}
  thrown in /phriction/phriction-to-github-wiki/includes/class.phabricatorexport.php on line 32
make: *** [Makefile:4: run] Error 255

seems to stem from the method

public function getDocument($id) {
		$query = sprintf('SELECT * FROM phriction_content WHERE documentID = %d ORDER BY version DESC LIMIT 1', $id);
		$row = $this->db->query($query);
		$row->setFetchMode(PDO::FETCH_CLASS, 'PhrictionDoc');
		return $row->fetch();
	}

The query filters based on a column called documentID, which doesn't exist in my table. I do have a documentPHID, a blob that resolves to 'PHID-WIKI-lo65uqwrhmxax4hxnwcs' -- in my case, this matches 21 rows. But the query above is filtering on the id, and the $id being passed in would never match the documentPHID.

Is the idea to return only the newest version of any particular document, in which case the getDocumentIndex() method might be changed to

public function getDocumentIndex() {
		$query = 'SELECT * FROM phriction_document ORDER BY depth ASC';
		$rows = $this->db->query($query);
		$rows->setFetchMode(PDO::FETCH_ASSOC);

		$return = array();
		while($row = $rows->fetch()) {
			$return[] = $this->getDocument($row['phid']);
		}
		return $return;
	}

and the getDocument() method would be changed to

	public function getDocument($phid) {
		$query = sprintf('SELECT * FROM phriction_content WHERE documentPHID = %d ORDER BY version DESC LIMIT 1', $phid);
		$row = $this->db->query($query);
		$row->setFetchMode(PDO::FETCH_CLASS, 'PhrictionDoc');
		return $row->fetch();
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant