Unable to get mongodb _id value in php - php

I tried a lot of tricks to get the value of mongodb _id, but all of them result in error. I tried these:
$new_id = new MongoId();
print_r($new_id['_id']); // -> Internal Server Error
echo $new_id['_id']->{'$id'}; // -> Internal Server Error
print_r($new_id); // no error, but useless
So, I wonder how to do it right

This code works for me:
$mongoId = new \MongoId();
$strId = $mongoId->__toString();
print_r($strId); die;
MongoId::__toString — Returns a hexidecimal representation of this
id
public string MongoId::__toString ( void )
http://php.net/manual/en/mongoid.tostring.php
Please check your server error logs otherwise.

Related

SOAP API / SQL Error "ORA 00904 invalid Identifier"

I have the following problem:
I need to get a few columns of a oracle db table to display information on a .php page. To do this, I'm using a SOAP-API, which works flawlessly with any other table, only not with this one.
This is the Code I am using for all of these Queries:
$setSearchObjectsIn = new SearchObjectsInType();
$setSearchObjectsIn->sessionId = (String) $sessionId;
$setSearchObjectsIn->table = (String) 'STFCFG_DD_VALUE';
$setSearchObjectsIn->caseSensitive = (String) 'false';
$setSearchObjectsIn->limitedResult = (String) 'false';
$setSearchObjectsIn->restrictions[0]['attributeName']= (String) 'STFCFG_DD_VALUE.DDID';
$setSearchObjectsIn->restrictions[0]['restriction']['operator'] = (String) '=';
$setSearchObjectsIn->restrictions[0]['restriction']['value'] = (String) $ddid;
$setSearchObjectsIn->resultColumns[0] = (String) 'STFCFG_DD_VALUE.DD_VALUE';
$setSearchObjectsIn->resultColumns[1] = (String) 'STFCFG_DD_VALUE.CATALOG_NAME';
$setSearchObjectsIn->resultColumns[2] = (String) 'STFCFG_DD_VALUE.MSG_ID';
$client = new SoapClient((String) $instance.'/axis/services/GenericApiWS?wsdl');
$result = $client->searchObjects($setSearchObjectsIn);
And this is the Error I get with this special table:
ORA-00904: "MAN_ID": ungültiger Bezeichner
I have also tried starting this query with SoapUI, which results in the exactly same thing.
The fact, that I have nothing like "MAN_ID" in my code has me wondering, as the error looks like I would query a column named like that, which I obviously don't do. (There is also no column "MAN_ID" in the requested table, so I have no idea where this comes from)
I hope you can help me
I'd try looking for MAN_ID in the SOAP server code - the error may be what the server returns and it may be looking for that column implicitly. The error message is definitely produced by Oracle, so search the way your query gets there and if possible, see what query gets executed.

Docusign API PHP TemplatesApi::updateDocument FORMAT_CONVERSION_ERROR

I'm trying to update a template document via PHP API using this: https://github.com/docusign/docusign-php-client/blob/master/src/Api/TemplatesApi.php#L4946
I get one of two errors depending on if I set the apply_document_fields option.
Without it set, I get UNSPECIFIED ERROR Value cannot be null.\r\nParameter name: fileBytes. However, if I view the request body before sending, document_base_64 is set as expected.
With apply_document_fields set 'true' (actual boolean value is not supported), I get FORMAT_CONVERSION_ERROR The data could not be converted.
Either way, it seems like the document data is not getting sent correctly, but I can't figure out how I'm supposed to be sending it. Here's my code:
public static function updateTemplateWithDocument(string $documentId, string $templateId, $documentBody = null)
{
$api = My_Service_Docusign::getInstance();
$templatesApi = new DocuSign\eSign\Api\TemplatesApi($api->getAuth());
$document = new \DocuSign\eSign\Model\Document();
$document->setDocumentBase64(base64_encode($documentBody));
// Got an error reusing $documentId, so I'm incrementing it now
$document->setDocumentId((string) (((int)$documentId) + 1));
$def = new DocuSign\eSign\Model\EnvelopeDefinition();
$def->setDocuments(array($document));
$opts = new \DocuSign\eSign\Api\TemplatesApi\UpdateDocumentOptions();
// Different behavior with this set vs not
$opts->setApplyDocumentFields('true');
$res = $tmpApi->updateDocument($api->getAccountId(), $documentId, $templateId, $def, $opts);
return $res;
}
Unfortunately, DocuSign support doesn't support their API :-(
I figured out I need to use TemplatesApi::updateDocuments (plural) instead, which also allows me to reuse the documentId.

PHP 5X.X is sending zero as value to any SOAP service

I have a webservice with one one method that reurns an objetc, the method is very simple getObject(int id);
I made a PHP client to test it:
<?php
ini_set("soap.wsdl_cache_enabled", "1"); // Set to zero to avoid caching WSDL
$soapClient = new SoapClient('http://localhost:8080/ws-tickets/tickets2?wsdl');
$id = 2;
$result = $soapClient->get Ticket($id);
print_r($result);
?>
Well, I debug the WS when it is called by this php client and I see that the parameter received by it is ZERO.
If in my database I create a record that has "0" as id, the phpclient will retrieve it perfectly and every data is printed as it supouse to be for the print_r($result); command.
But, no mather wich parameter I send, it allways came to ZERO to the ws and I do not know what I am doing wrong
My Java WS is
#WebService
public class tickets2 {
#EJB
reciboDAO reciboDAO;
public ticket getTicket(int id){
recibo a = this.reciboDAO.getReciboporid(id);
return a;
}
}

How do I loop through an MS SQL database with VB.NET?

I'm trying to implement the following php code in visual basic. I wrote it in PHP because I knew I could do what I wanted to in that language, but I can't for the life of me figure out how to get it working in Visual Basic to loop through a MS SQL database.
$link = mysqli_connect('localhost', 'my_user', 'my_password', 'FakeDB');
$result = mysqli_query($con,"SELECT * FROM FakeDB");
$concatDupes = Array();
for ( $i = 0, $i< count($result), $i++) {
if ( $result[$i] == $result[$i + 1] {
array_push($concatDupes,$result[$i] + $result[$i + 1])
} else {
array_push( $concatDupes, $result[$i])
}
}
I've tried to use the code in this post but to no avail. (I put MsgBox("hello") inside the while loop and nothing happened) I've also attempeted the following, also with zero success.
Dim i = Me.PaymentTableAdapter.GetData().HazWasteAmtColumn.ToString()
MsgBox(i) 'no message box
Dim i = Me.PaymentTableAdapter.GetData().Count
MsgBox(i) ' also no message box
Dim i = Me.PaymentTableAdapter.GetData().Count
MsgBox(GetType(i)) 'type of i is not defined
I know my query is returning results because it works fine in a DataGridView.
Other useful info:
Watching the i (any of the i's referenced above) always shows Nothing, no matter what I've tried.
Here's what happens when I call Public Sub ReadData(ByVal connectionString As String, ByVal queryString As String) (full function in linked page) with:
Dim connect = WindowsApplication1.My.Settings.ShopMgtConnectionString
Dim querty As String = "SELECT * "
querty = querty + "FROM SM.PartItem "
ReadData(connect, querty)
immediate window output (the error list shows nothing):
A first chance exception of type 'System.ArgumentException' occurred in System.Data.dll
A first chance exception of type 'System.ArgumentException' occurred in System.Data.dll
A first chance exception of type 'System.ArgumentException' occurred in System.Data.dll
A first chance exception of type 'System.Data.ConstraintException' occurred in System.Data.dll
A first chance exception of type 'System.ArgumentException' occurred in System.Data.dll
EDIT: Here's the ReadData() method
Public Sub ReadData(ByVal connectionString As String, _
ByVal queryString As String)
Using connection As New OleDbConnection(connectionString)
Dim command As New OleDbCommand(queryString, connection)
connection.Open()
Dim reader As OleDbDataReader = command.ExecuteReader()
While reader.Read()
Console.WriteLine(reader(0).ToString())
End While
reader.Close()
End Using
End Sub
EDIT, Again...
I've taken a screen recording of the program running. It's just not doing anything useful.
http://youtu.be/i7oNVDXUw78
Make sure you are reading non null data:
While reader.Read()
If reader.IsDBNull(0) = False Then
Console.WriteLine(reader.GetValue(0).ToString())
End If
End While

Why php's soapCall gives string conversion error?

// Set username and password
$ih_soap_user= $this->config->item('interUser');
$ih_soap_pass=$this->config->item('interPass');
//echo $ih_soap_user.':P:'.$ih_soap_pass;
// Set soap namespace
$ih_soap_ns = 'http://www.interhome.com/webservice';
// Create new instance of SoapClient with the interhome web service URL
$client = new
SoapClient($this->config->item('interSoap'),array('trace'=>'1'));
// Create new soap header and set username and password
$header = new SoapHeader($ih_soap_ns,
'ServiceAuthHeader',
array('Username' => $ih_soap_user,'Password' =>
$ih_soap_pass),
true
);
// Prepare p// Prepare parameters
$params = array('inputValue' =>array(
'Page'=>$page,
'PageSize'=>'10',
'OrderDirection'=>'Ascending',//Descending
'OrderBy'=>'Price',//Favorite,Place
'LanguageCode'=>'EN',
'CurrencyCode'=>'EUR',
'CountryCode'=>trim($ajaxSearchCountryCode),
'RegionCode'=>trim($ajaxSearchRegionCode),
'PlaceCode'=>$ajaxSearchPlaceCode,
'CheckIn'=> $ajaxSearchCheckinDate,
'Duration'=>'7',
'ThemeFilter'=>$ajaxSearchTheme,
'HouseApartmentType'=>array('House'=>'House'),
'SpecialOffer'=>'AnySpecialOffer',
'PaxMin'=>'1',
'PaxMax'=>'',
'RoomsMin'=>'1',
'RoomsMax'=>'',
) );
try{
$result = $client->__soapCall("Search",array('parameters'=> $params),null,$header);
Hi guys..Any Idea why this call when I pass any not empty array, as for example ,as I made for 'HouseApartmentType', returns this error
A PHP Error was encountered
Severity: Notice Message:
Array to string conversion
Filename:
controllers/houses.php Line
Number: 269
And when it's only empty array or a string the soap call function is working... I need to pass array of options to one parameter....
LINE 269 is
$result = $client->__soapCall("Search",array('parameters'=> $params),null,$header);
This is probably solved already, but I also had problems with this and I thought I should post here when I finally found the solution. (The solution is not nusoap, it throws the same error.)
The error only seems to come from the soapCall call generation, it really is the Web Service that causes it. When you run __soapCall, it first asks the server which datatypes the parameters should have and then tries to comply. So if you try to feed an array when the service expects a string, it will do the array to string conversion when the request is generated.
i think you should look at the manual how a soapcall work:
$params = array(
'Page'=>$page,
'PageSize'=>'10',
'OrderDirection'=>'Ascending',//Descending
'OrderBy'=>'Price',//Favorite,Place
'LanguageCode'=>'EN',
'CurrencyCode'=>'EUR',
'CountryCode'=>trim($ajaxSearchCountryCode),
'RegionCode'=>trim($ajaxSearchRegionCode),
'PlaceCode'=>$ajaxSearchPlaceCode,
'CheckIn'=> $ajaxSearchCheckinDate,
'Duration'=>'7',
'ThemeFilter'=>$ajaxSearchTheme,
'HouseApartmentType'=>'House', // changed to string instead of array
'SpecialOffer'=>'AnySpecialOffer',
'PaxMin'=>'1',
'PaxMax'=>'',
'RoomsMin'=>'1',
'RoomsMax'=>'' );
i simplified the array and you should test it and look if this is the kind of result you are looking for.
Also look for ordering errors like the example shown in php.net

Categories