|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How to concat BLOB values in PHP ? |
« View previous topic :: View next topic » |
Author |
Message
|
Herbert |
Posted: Thu Mar 14, 2013 8:33 am Post subject: How to concat BLOB values in PHP ? |
|
|
 Centurion
Joined: 05 Dec 2006 Posts: 146 Location: Leersum, The Netherlands
|
Is the PHP concat operator (the dot) not possible with BLOB values in a PHP compute node ?
TEST1 & TEST2 both works.
TEST3 & TEST4 give the runtime exception 2328 - "A value of SQL datatype ''CHARACTER'' encountered when datatype ''BLOB'' expected. "
imho thats strange because TEST1 & TEST2 proofs that both left and right of the . are BLOB values.
Code: |
class TEST1 {
/**
* @MessageBrokerSimpleTransform
*/
function evaluate($out, $in) {
$out->BLOB->BLOB = $in->BLOB->BLOB;
}
}
class TEST2 {
/**
* @MessageBrokerSimpleTransform
*/
function evaluate($out, $in) {
$blob = new MbsBlob();
$blob->setValue("\nNew line");
$out->BLOB->BLOB = $blob;
}
}
class TEST3 {
/**
* @MessageBrokerSimpleTransform
*/
function evaluate($out, $in) {
$blob = new MbsBlob();
$blob->setValue("\nNew line");
$out->BLOB->BLOB = $in->BLOB->BLOB . $blob;
}
}
class TEST4 {
/**
* @MessageBrokerSimpleTransform
*/
function evaluate($out, $in) {
$blob = new MbsBlob();
$blob->setValue("\nNew line");
$out->BLOB->BLOB = $in->BLOB->BLOB;
$out->BLOB->BLOB .= $blob;
}
} |
|
|
Back to top |
|
 |
mqjeff |
Posted: Thu Mar 14, 2013 8:40 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I'd say that MbsBlob . MbsBlob produces a String, not another MbsBlob.
Code: |
$out->BLOB->BLOB = new MbsBlob($in->BLOB->BLOB . $blob); |
|
|
Back to top |
|
 |
Herbert |
Posted: Thu Mar 14, 2013 9:28 am Post subject: |
|
|
 Centurion
Joined: 05 Dec 2006 Posts: 146 Location: Leersum, The Netherlands
|
Thanks, the . is a string operator so it returns a String and not a BLOB, that makes sence.
The input of new MbsBlob() must be a String, below is working now.
Code: |
class TEST5 {
/**
* @MessageBrokerSimpleTransform
*/
function evaluate($out, $in) {
$blob = new MbsBlob();
$blob->setValue("\nNew line");
$out->BLOB->BLOB = new MbsBlob( $in->BLOB->BLOB->getValue()->getValue() . $blob->getValue() );
}
} |
The $blob->getValue() is clear I think
The $in->BLOB->BLOB->getValue()->getValue() is somewhat funny, the first getValue returns an object of type MbsBlob the second returns the string value from that object.
I don't think it's good code ...
$out->BLOB->BLOB is a MbsElement which has the setValue() Method, maybe thats a better way. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Mar 14, 2013 9:35 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I make no claims to providing any information on the right way to do things in PHP...
working things, maybe. |
|
Back to top |
|
 |
Herbert |
Posted: Thu Mar 14, 2013 11:50 pm Post subject: |
|
|
 Centurion
Joined: 05 Dec 2006 Posts: 146 Location: Leersum, The Netherlands
|
mqjeff wrote: |
I make no claims to providing any information on the right way to do things in PHP...
working things, maybe. |
I understand, it was a general thought, and indeed, it's good to have working things
It was a simple request, adding a MD5 string to a existing message, below is working now.
Code: |
<?php
class MD5 {
/**
* @MessageBrokerSimpleTransform
*/
function evaluate($out, $in) {
$message = $in->BLOB->BLOB->getValue()->getValue();
$md5 = "\n" . "MD5: " . md5($message);
$out->BLOB->BLOB = new MbsBlob ( $message . $md5 );
}
}
?> |
First time I did use PHP with WMB, I know it exists for many years, it was fun to see if I could implement this request with PHP inside WMB.
Not sure if I will bring it to production, or that I will just do a java compute node. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|