Skip to content

Column mismatch error #4

Description

@oxwilder

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();
	}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions