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.
Related
I think I've worked out that the issue relates to binding params for PDO instead of including the values in the select statement.
Now googling how to bind array values where there will be a variable number of them per query type. For example there may be one, two or three category (col) values sought.
My primary script submits an ajax request to a secondary script.
Two params are sent and are being received in most scenarios.
eg department:mens-fashion, category:coats-and-jackets
In all but a few scenarios, the ajax query is successful and returns as expected. However, for some pairings of params, nothing is displayed in the page or in console.
Having returned from the query script immediately after building the query, I know the query is always working OK. (Copying and pasting into phpMyAmdin brings me the correct resultset.)
So it seems the key part of the script is the fetch routine. How can I catch an error message from PDO in the next line?...
$filtered_results = $filtered_statement->fetchAll(PDO::FETCH_ASSOC);
$debugInfo = array('debug' => vsprintf(str_replace("?", "%s", $filtered_statement->queryString), $opts ));
[edit]
if ( is_array($filtered_results) ) {
$filtered_results = array_merge($debugInfo, $filtered_results);
} else {
$filtered_results = $debugInfo;
}
[/edit]
debug info still only being returned if the query was a success.
$filtered_results_json = json_encode($filtered_results);
echo( $filtered_results_json );
Please would anyone point me to a solution where, the failed query will display in the calling script. The data required is in the db so I am still really stuck on trying to display failure messages.
You need to check whether an array is returned or not. If nothing was found no array is being returned - and you can't use array_merge.
$filtered_results = $filtered_statement->fetchAll(PDO::FETCH_ASSOC);
$debugInfo = array('debug' => vsprintf(str_replace("?", "%s", $filtered_statement->queryString), $opts ));
if ( is_array($filtered_results) ) {
$filtered_results = array_merge($debugInfo, $filtered_results);
} else {
$filtered_results = $debugInfo;
}
$filtered_results_json = json_encode($filtered_results);
echo( $filtered_results_json );
See this as well: Value return when no rows in PDO
I' creating solr document via solarium plugin in php.
But the all document is stored text_general data type except id field. text_general is the default datatype in solr system.
My doubt is why id field is only to stored string type as default.
And If any possible to add document with string type using solarium plugin.
My code part is here,
public function updateQuery() {
$update = $this->client2->createUpdate();
// create a new document for the data
$doc1 = $update->createDocument();
// $doc1->id = 123;
$doc1->name = 'value123';
$doc1->price = 364;
// and a second one
$doc2 = $update->createDocument();
// $doc2->id = 124;
$doc2->name = 'value124';
$doc2->price = 340;
// add the documents and a commit command to the update query
$update->addDocuments(array($doc1, $doc2));
$update->addCommit();
// this executes the query and returns the result
$result = $this->client2->update($update);
echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime();
}
The result document for the above code is here,
{
"responseHeader":{
"status":0,
"QTime":2,
"params":{
"q":"*:*",
"_":"1562736411330"}},
"response":{"numFound":2,"start":0,"docs":[
{
"name":["value123"],
"price":[364],
"id":"873dfec0-4f9b-4d16-9579-a4d5be8fee85",
"_version_":1638647891775979520},
{
"name":["value124"],
"price":[340],
"id":"7228e92d-5ee6-4a09-bf12-78e24bdfa52a",
"_version_":1638647892102086656}]
}}
This depends on the field type defined in the schema for your Solr installation. It does not have anything to do with how you're sending data through Solarium.
In the schemaless mode, the id field is always set as a string, since a unique field can't be tokenized (well, it can, but it'll give weird, non-obvious errors).
In your case i'd suggest defining the price field as an integer/long field (if it's integers all the way) and the name field as a string field. Be aware that string fields only generate hits on exact matches, so in your case you'd have to search for value124 with exact casing to get a hit.
You can also adjust the multiValued property of the field when you define the fields explicitly. That way you get only the string back in the JSON structure instead of an array containing the string.
I have the following SQLite table
CREATE TABLE keywords
(
id INTEGER PRIMARY KEY,
lang INTEGER NOT NULL,
kwd TEXT NOT NULL,
count INTEGER NOT NULL DEFAULT 0,
locs TEXT NOT NULL DEFAULT '{}'
);
CREATE UNIQUE INDEX kwd ON keywords(lang,kwd);
Working in PHP I typically need to insert keywords in this table, or update the row count if the keyword already exists. Take an example
$langs = array(0,1,2,3,4,5);
$kwds = array('noel,canard,foie gras','','','','','');
I now these data run through the following code
$len = count($langs);
$klen = count($kwds);
$klen = ($klen < $len)?$klen:$len;
$sqlite = new SQLite3('/path/to/keywords.sqlite');
$iStmt = $sqlite->prepare("INSERT OR IGNORE INTO keywords (lang,kwd)
VALUES(:lang,:kwd)");
$sStmt = $sqlite->prepare("SELECT rowid FROM keywords WHERE lang = :lang
AND kwd = :kwd");
if (!$iStmt || !$sStmt) return;
for($i=0;$i < $klen;$i++)
{
$keywords = $kwds[$i];
if (0 === strlen($keywords)) continue;
$lang = intval($langs[$i]);
$keywords = explode(',',$keywords);
for($j=0;$j < count($keywords);$j++)
{
$keyword = $keywords[$j];
if (0 === strlen($keyword)) continue;
$iStmt->bindValue(':kwd',$keyword,SQLITE3_TEXT);
$iStmt->bindValue(':lang',$lang,SQLITE3_INTEGER);
$sStmt->bindValue(':lang',$lang,SQLITE3_INTEGER);
$sStmt->bindValue(':kwd',$keyword,SQLITE3_TEXT);
trigger_error($keyword);
$iStmt->execute();
$sqlite->exec("UPDATE keywords SET count = count + 1 WHERE lang =
'{$lang}' AND kwd = '{$keyword}';");
$rslt = $sStmt->execute();
trigger_error($sqlite->lastErrorMsg());
trigger_error(json_encode($rslt->fetchArray()));
}
}
which generates the following trigger_error output
Keyword: noel
Last error: not an error
SELECT Result: {"0":1,"id":1}
Keyword: canard
Last Error: not an error
SELECT Reult:false
Keyword:foiegras
Last Error: not an error
SELECT Result: false
From the SQLite command line I see that the three row entries are present and correct in the table with the id/rowid columns set to 1, 2 and 3 respectively. lastErrorMsg does not report an error and yet two of the three $rslt->fetchArray() statements are returning false as opposed to an array with rowid/id attributes. So what am I doing wrong here?
I investigated this a bit more and found the underlying case. In my original code the result from the first SQLite3::execute - $iStmt-execute() - was not being assigned to anything. I did not see any particular reason for fetching and interpreting that result. When I changed that line of code to read $rslt = $iStmt->execute() I got the expected result - the rowid/id of the three rows that get inserted was correctly reported.
It is as though internally the PHP SQLite3 extension buffers the result from SQLiteStatement::execute function calls. When I was skipping the assignment my next effort at running such a statement, $sStmt->execute() was in effect fetching the previous result. This is my interpretation without knowing the inner workings of the PHP SQLite3 extension. Perhaps someone who understands the extension better would like to comment.
Add $rslt = NONE; right after trigger_error(json_encode($rslt->fetchArray())); and the correct results appear.
FetchArray can only be called once and somehow php is not detecting that the variable has changed. I also played with changing bindValue to bindParam and moving that before the loop but that is unrelated to the main issue.
It is my opinion that my solution should not work unless there is a bug in php. I am too new at the language to feel confident in that opinion and would like help verifying it. Okay, not a bug, but a violation of the least surprise principle. The object still exists in memory so without finalizing it or resetting the variable, fetch array isn't triggering.
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.
I am working on project where I need to implement SphinxSearch with Cake php. So I am simply trying to use a component and behaviour into it. The link to it, is :-
http://bakery.cakephp.org/articles/eugenioclrc/2010/07/10/sphinx-component-and-behavior
I am requesting Sphinx API like below :
$sphinx = array('matchMode' => SPH_MATCH_ALL, 'sortMode' => array(SPH_SORT_EXTENDED => '#relevance DESC'));
$results = $this->ModelName->find('all', array('search' => 'Search_Query', 'sphinx' => $sphinx));
pr($result);
For above it is working fine ,but when I tried to minimise the response time querying to a particular field of the table (using extended match modes,i.e. SPH_MATCH_EXTENDED2) , Sphinx just fails to output any result. The extended query which I used is given below :-
$sphinx = array('matchMode' => SPH_MATCH_EXTENDED2, 'sortMode' => array(SPH_SORT_EXTENDED => '#relevance DESC'));
$results = $this->ModelName->find('all', array('search' => '#Field_name Search_Query', 'sphinx' => $sphinx));
pr($results);
Can anyone recognise where am I going wrong with it? Please help if I am going wrong some where.
Thanks in advance.
Btw, when you use EXTENDED2 mode make sure your rank mode is set accordingly.
Edit:
Anyway back to you problem, looking at that component/behavior code you can see right away that no error checking is done whatsoever. Try changing the code a bit so you can at least see the errors and/or warnings.
Component
if(!isset($query['search'])){
$result = self::$sphinx->Query('', $indexes);
} else {
$result = self::$sphinx->Query($query['search'], $indexes);
}
if ($result === false) {
// throw new SphinxException();
die(self::$sphinx->GetLastError());
}
$warn = self::$sphinx->GetLastWarning();
if ($warn) echo $warn;
Behavior
$result=$this->runtime[$model->alias]['sphinx']->search($s);
if ($result === false) {
die($this->runtime[$model->alias]['sphinx']->GetLastError());
}
$warn = $this->runtime[$model->alias]['sphinx']->GetLastWarning();
if ($warn) echo $warn;
I hope that helps.
As you said ,
Sphinx just fails to output any result.
That means it's an error :
Please check whether you have added the specific field to the indexing by using sql_query
Also check if the field you are searching for is not an attribute
As per the sphinx documentation :
Attributes, unlike the fields, are not full-text indexed. They are stored in the index, but it is not possible to search them as full-text, and attempting to do so results in an error.