NYCPHP Meetup

NYPHP.org

[nycphp-talk] PEAR::DB prepare() and executeMultiple()

Jeff Loiselle jeff.loiselle at gmail.com
Fri Mar 18 17:24:50 EST 2005


Hello everyone,

I need some eyes on this code.. I've been staring at it for too long..
and I dont know where to go for more debugging info.  I am using
Oracle and I get this error:

DELETE FROM ? WHERE DOC_ID=? [nativecode=ORA-00903: invalid table name]

I've checked the table names and tried just one at a time. Am I doing
something syntactically wrong? Where can I get more debuggin
information?

I know it's probably something really simple that I'm overlooking.

Thanks in advance.. sorry if this isn't appropriate.

------------------

$this->dbh->autoCommit(false);
  	
  	$sth = $this->dbh->prepare('DELETE FROM ? WHERE DOC_ID=?');
  	
  	if (PEAR::isError($sth)) {
  		trigger_error('Error preparing statements for document
delete:'.$sth->getUserInfo(), E_USER_ERROR);
  	}
  	
  	// Set array of tables where records will be removed
  	$data = array(array('APPROVAL_STATUS', $doc_id),
  				  array('AUTHORS', $doc_id),
  				  array('CORE_MATERIALS_FILENUM', $doc_id),
  				  array('DISCLOSURE', $doc_id),
  				  array('DOCUMENT', $doc_id),
  				  array('DOCUMENT_IMAGE', $doc_id),
  				  array('INTELLECTUAL_PROPERTY', $doc_id),
  				  array('KEYWORDS', $doc_id),
  				  array('PI_VERSION', $doc_id),
  				  array('SIGNATURES', $doc_id));
  				 
  	$res = $this->dbh->executeMultiple($sth, $data);
  	if (PEAR::isError($res)) {
  		$rollback = $this->dbh->rollback();
  		if (PEAR::isError($rollback)) {
  			trigger_error('Error while attempting to rollback document
delete:'.$rollback->getUserInfo(), E_USER_ERROR);
  		}  		
  		trigger_error('Error executing delete statements for document
delete:'.$res->getUserInfo(), E_USER_ERROR);
  	}
  	
  	$commit = $this->dbh->commit();
  	if (PEAR::isError($commit)) {
  		trigger_error('Error while commiting document
delete:'.$commit->getUserInfo(), E_USER_ERROR);
  	}

---
Jeff Loiselle
Web Developer, Musician, and Observer



More information about the talk mailing list