View Single Post
  #1 (permalink)  
Old 02-19-2007, 07:03 PM
chris_hird chris_hird is offline
Junior Member
 
Join Date: Feb 2007
Posts: 15
Default Problem DB->fetchall()

Hi

I am having problems with the above call. Here are the code segments which important plus a clip from the joblog created by the call.

Quote:
30 02/19/07 14:51:21.518832 QSQRUN1 QSYS *STMT QSQRUN1
From user . . . . . . . . . : QTMHHTTP
From module . . . . . . . . : QSQPREP
From procedure . . . . . . : CLEANUP
Statement . . . . . . . . . : 11025
To module . . . . . . . . . : QSQPREP
To procedure . . . . . . . : CLEANUP
Statement . . . . . . . . . : 11025
Message . . . . : Column CHRISH not in specified tables.
Cause . . . . . : CHRISH is not a column of table *N in *N. If the table
*N, CHRISH is not a column of any table or view that can be referenced.
Recovery . . . : Do one of the following and try the request again: --

Here is the code for the call.

Quote:
$params = array(
'host' => 'localhost',
'username' => '',
'password' => '',
'dbname' => 'S1062EBB'
);

try {
$DB = Zend_Db::factory('Db2' , $params);
}
catch (Exception $e) {
die("Failed in factory " . $e->getMessage());
}

$select = $DB->select();
$select->from('SHIELDCRM.USERS', '*');
$select->where('USRNAME = ?', $_POST['username']);
$select->where('PASSWD = ?', $_POST['password']);
$sql = $select->__toString();
echo $sql;

try {
$rowsFound = $DB->fetchAll($select);
}
catch (ErrorException $e){
die("Failed fetchall" . $e->getMessage());
}

if (isset($rowsFound[0]["username"])) {
echo "found row";
$this->_redirect('/');
}

else {
echo "Login information incorrect. Please <a href='/user/login'>try again</a>.";
}
The echo of the statement shows the following..

Quote:
SELECT * FROM SHIELDCRM.USERS WHERE USRNAME = chrish AND PASSWD = password
Warning: db2_prepare() [function.db2-prepare]: Statement Prepare Failed in /www/shieldcrm/library/Zend/Db/Statement/Db2.php on line 258

Warning: db2_stmt_errormsg() expects parameter 1 to be resource, boolean given in /www/shieldcrm/library/Zend/Db/Statement/Db2.php on line 261

Warning: db2_stmt_error() expects parameter 1 to be resource, boolean given in /www/shieldcrm/library/Zend/Db/Statement/Db2.php on line 261
I using a normal login page and the above print shows the POST variables are correctly sent to the SELECT object...

Why is it being converted to show the CHRISH as a column not an entry in the column

here is the DB it should be reading.
Quote:
Display Physical File Member
File . . . . . . : USERS Library . . . . : SHIELDCRM
Member . . . . . : USERS Record . . . . . : 1
Control . . . . . Column . . . . . : 1
Find . . . . . . .
*...+....1....+....2....+....3....+....4....+....5 ....+....6....+....7..
Chris Hird chrish@shield.on.ca
Alison Hird alison@shield.on.ca
.8....+....9....+....0....+....1....+....2....+... .3....+....4....+....5....+.
chrish nopass
alison passwo
These appear to be right and I can update using the DB->insert OK?

Chris..
Reply With Quote