i thought that all errors were non responss pretty much, and thus if
anything was returned, it is a success.
In some of my other code, i check for the existance of an error and then
return on that check. But that is using pear classes of _Error and _MDB2
here's one of the methods:
public function doSomethingOne($operation, $incomingdata, $id=NULL) {
$data = array(
'per_id' => $incomingdata['per_id'],
'val_one' => $incomingdata['val_one'],
's_id' => $incomingdata['s_id'],
);
if ($operation == 'insert') {
$data['uni_id'] = $this->_u;
$res = $this->_db->insert('block_table', $data);
} elseif ($operation == 'update') {
$res = $this->_db->update('block_table', $data,
'block_table_id = '.$this->_u.'
AND id = '.$id);
}
if ($res)
{ return true; }
else
{ return false; }
}
Kevin Hallmark wrote:
>
> Are the queries returning SQL errors or just not performing the action
> properly?
>
> That block will only rollback if an actual exception is thrown. If the
> query
> just isn't producing the correct result, then you should check that in the
> try block and throw your own exceptions.
>
> Kevin
>
>
> On 7/31/08 2:23 PM, "maxarbos" <maxarbos@yahoo.com> wrote:
>
>>
>> Hello,
>>
>> i have a question about Zend_DB
>>
>> 1: I am using transactions and it seems that my try block is not working
>> correctly.
>>
>> Here is the code:
>>
>> $this->_db->beginTransaction();
>>
>> try {
>> $this->block->doSomethingOne($one_info_action, $vals);
>> $this->block->doSomethingTwo($two_info_action, $vals);
>>
>> $this->_db->commit();
>>
>> } catch (Exception $e) {
>> $this->_db->rollBack();
>> echo $e->getMessage();
>> }
>>
>>
>> Is this valid? Will the transaction and try block work correctly (if
>> doSomethingOne and doSomethingTwo both succeed, then and only then, do
>> the
>> results commit)? I have a block just like this, but it seems as though
>> some
>> of the methods succeed, while others dont. Can methods be checked within
>> a
>> try/transaction block? (i hope this makes sense)
>>
>> Thanks.
>
>
>
--
View this message in context: http://www.nabble.com/_DB-%2C-Transactions-usage-questions-tp18760601p18760941.html
Sent from the Zend DB mailing list archive at Nabble.com.
没有评论:
发表评论