table contain 1304 records but after running the script given below it shows only the last record 1304 times. so please help me.is it possible to fetch multiple records from filemaker,i dont have any idea.
<?php include ("dbaccess.php");?>
<?php
//Create the 'find all' command and specify the layout
$findCommand = $fm->newFindAllCommand('eventsROY');
//Perform the find and store the result
$result = $findCommand->execute();
//Check for an error
if (FileMaker::isError($result)) {
echo "<p>Error: " . $result->getMessage() . "</p>";
exit;
}
//Store the matching records
$records = $result->getRecords();
//print_r($records);
echo $cnt = count($records);
foreach($records as $rc){
$time = $rc->getField('time');echo "<pre>";
print_r($time);
echo "<pre>";
}
?>
This question is super old so I'm not sure if it's still an issue, but if it is maybe I can help.
What do the fields look like on your layout eventsROY layout? More importantly, are they all coming from the layout's native Table Occurrence or are some of them, time specifically, coming from a different related table?
Your structure is correct. I cleaned it up a little here:
<?php
include ("dbaccess.php");
//Create the 'find all' command and specify the layout
$findCommand = $fm->newFindAllCommand('eventsROY');
//Perform the find and store the result
$result = $findCommand->execute();
//Check for an error
if (FileMaker::isError($result)) {
echo "<p>Error: " . $result->getMessage() . "</p>";
exit;
}
//Store the matching records
echo $count = $result->getFetchCount();
foreach($result->getRecords() as $record){
$time = $record->getField('time');
echo "<pre>";
print_r($time);
echo "<pre>";
}
?>
So, if you're getting the record count you expect from the eventsROY table, it means that the query is working and if you're getting a value (even if it's wrong) from the time field it means that field is available on the eventsROY layout.
The way I could see this pulling the same time value over and over is if time is a field from a related table and the relationship for that related table using the same related record for every record in your eventsROY table. For example, if you had a table called schedule that was related to the eventsROY table by a cartesian join (X) then when you look at the schedule::time field from any eventsROY record the value would be the same because it's using the first related record from the schedule table to show the value.
What you should do to troubleshoot this is:
Go to your eventsROY layout in FileMaker and see if the time field is coming from the eventsROYtable or a different related table
If it is coming from the eventsROY table and is a calculation, make sure the calculation is being Evaluated from the eventsROY table occurrence (if it's being evaluated from a different TO that could cause an issue too)
Back in your php, try using a print_r($record) in place of your print_r($time) just to make sure that the rest of your fields are also returning the expected response
Related
everyone.
I'm doing an tool with Perl that actually verifies a status in the database and if necessary it gets the properly queries and after confirmation it updates the value.
The page has three possible contents:
If the query that will be used is already filled it updates and returns the status.
If only the serial that the user input is filled it generates the query and then asks for confirmation.
If none of those 2 variables are already filled it goes to the main form where the user can submit the serial.
The problem that I'm facing is that after it generates the $final_query and shows up for confirmation, when I click the Confirm button it reloads the page but it pass directly through the if($final_query) and even the elseif that verifies if the $serial_no is already set.
Does Perl really lose those values if I perform a second submit or am I doing something wrong?
I'd love to have some explanation about it because it's the second time that I'm doing something with that language.
Thanks in advance!
--edit
I chopped the code to show where it defines the $final_query but I kept the structure to help in the understanding.
The full code is available at http://pastebin.com/6NqhbVau
#headers
if ($final_query) {
$content = "<h1>first if</h1>";
#updateESNDatabase($database, $final_query);
#it only enters here if the user type the ESN
}elsif ($serial_no) {
#selects the database
switch(checkUpdateNeeded($database, $serial_no)) {
case 0 {
#Shows that the updates are no needed
}
case 1 {
$final_query = `cat $query1`;
chop($final_query);
$final_query =~ s/SERIALNUM/$serial_no/g;
$final_query =~ s/LOGINID/$login_id/g;
$content = $cgi->start_form .
"<center>" .
"<h3> Please double check the queries below before you update on database </h3>" .
"</center>" .
$cgi->submit("Confirm") . $cgi->end_form;
$content .= $final_query;
}
case 2 {
#Makes almost the same as the first case, it only uses a different file to generate the query.
}
}
} else {
#Generates the first page, where the users inputs information
}
$page->set_content($content);
$page->process;
I figured out how to perform this.
As per my analysis I cannot simply create a variable and pass it through the cgi form.
To workaround this what I've done is create a hidden input in HTML and then send the variable through it.
<input type='hidden' name='the_query' value=\"$final_query\">
I have a problem with creating default value of 'All values' for a cascading parameter group last parameter. Actually I don't neccesary need that value to be default, but that would be preferable.
I have tried where I create additional data set with the needed value and additional data set with value All which uses different scripted data source, and another data set with computed column with full outer join, that column uses this code
if(row["userName"]==null ){
row["All"];
}else{
row["userName"];
}
and in the last cascaded parameter JDSuser which I need that All value I have added default value (All users).
In the data set with one value All in open I have script
ii=0;
in fetch
if( ii > 0 ){
return false;
}else{
row["All"] = "(All Users)";
ii++
return true;
}
and in the query data set, in beforeOpen script in if statement I have
if( params["JDSuser"].value!=null && params["JDSuser"].value[0] != "(All Users)" ){
This is used if I haven't selected All users value, and this works, though if I select All Users, it retrieves me no data.
I'm creating from this source example actuate link for example rptdesign download
If someone could give me some help, I would be very grateful.
The way you generate "(All values)" item in your selection list seems to me over complicated but if i understood correctly your case this part is working fine, the problem is not in the definition of the cascading parameter but the way it is used in the main dataset of the report.
Furthermore we have to assume we speak about the same query & beforeOpen script involved in this topic. No data are returned because if we don't do anything special when this item "All values" has been selected, then those filters are still active:
and role.name in ( 'sample grupa' )
and userbase.userName in ( 'sample' )
There are a couple of options to handle this. An elegant one is to declare a dataset parameter linked to your report parameter "JDSuser", and use a clause "OR" such:
and role.name in ( 'sample grupa' )
and (?='(All users)' OR userbase.userName in ( 'sample' ))
Notice this question mark, which represents a dataset parameter in your query. It is not intrusive: the beforeOpen script doesn't have to be changed. You probably need to do something similar with the other filter role.name, but you don't provide any information related to this. One more thing, in order to avoid bad surpises may be you should choose as value something more simple without brackets such "_allitems", and set "(All items)" as label.
Please refer to this topic for more informations about handling optional parameters. See a live example of optional parameters in a cascading group here.
I have to get two different names pulled from this query, the Account Name and the Opportunity Name. Both are called "Name" under each object.
I am able to use a query to retrieve both of them, but I am unable to decipher between the two in order to actually echo/print or use them.
My Query is:
$query = "SELECT Name,Opportunity.Account.Name from Opportunity ";
$response = $mySforceConnection->query($query);
foreach ($response->records as $record) {
echo $record->Name ."<br/>\n";
//echo $record->Opportunity.Account.Name ."<br/>\n";
echo "<br/>\n"; }
The only Name that is displayed is the opportunity Name (when trying different methods, I know the code above will only echo that)
I have made two seperate queries one from account and one from opportunity to ensure both are infact different things, and they are.
I have attempted to echo two "Name" records, both are just the opportunity name it doesn't recognize the account name.
And obviously what is commented out above as "Opportunity.Account.Name" isn't echoing the result, i am recieving an error instead.
I know using an alias is not supported in salesforce so that obviously didn't and won't work, by that I mean trying to do this:
Select Name as OppName
I am unable to find a different way to echo the records, I have done a lot of googling on the subject. Any help would be appreciated or a point in the right direction.
In my schema there is no Name field in the Opportunity object. There is Account Name and it is a lookup on Account Name in the Account object. You can view the schema builder by going to Setup > Schema Builder (it is under App Setup).
To be honest, I don't know why this worked. I'm new to SOAP and Salesforce, so I was just trying different things to get it working. But if anyone else has this problem, this is how I fixed it.
I displayed the account name by using this to echo it:
echo $record->Account->Name ;
The query is still the same as in the question.
I want to display the number of images uploaded to an imagefield, in a views field or views tpl.php. How can I do this? My imagefield is called boatimages. I tried this but it comes out as 0, not the correct number: < ? php print count($fields->field_boatimages) ?>
Ack. I do not think count() works like that.
Why not just do this using Views? Take a look at Arguments > Settings and you'll see 'display record count' which seems like all you would need for this.
My suggestion is install the devel module and use the function dpm to print the variable if you wanna know the structure (print_r() may work too). If count isn't working it's because, you are probably using it with the wrong data.
OR, you could just query the database for the field. I'm gonna provide you instructions for drupal 7 but drupal 6 should be similar.
Check the table field_data_field_boatimages. See how there's a list of your images related with a single entity_id
Then execute this query
SELECT COUNT(*) FROM `field_data_field_boatimages` WHERE entity_id = ###
Where ### is the entity_id you want to know. You can get it by looking for arg(1) if arg(0) == node in your page.
Now you just have to use php power to print thar result
$query = SELECT COUNT(*) FROM `field_data_field_boatimages` WHERE entity_id = :eid
$result = db_query($query, array(':eid', $nid))->fetchField();
echo $result;
Drupal 6 would be very similar. Just a little difference in the table names and the query syntax. For example using db_result instead of fetchField()
Anyway good luck!
i am trying to make a simple selection in a wordpress table (created by a plugin). the table is named reduceri , and has the following columns: id, post, category.
so, i am trying to take all the category values, when the post is equal to the current post id.
the way i am doing the query is:
$the_query = "
SELECT $wpdb->reduceri.category
FROM $wpdb->reduceri
WHERE $wpdb->reduceri.post = ".$post_id."
";
$my_reduceri = $wpdb->get_results($the_query);
but when i var_dump the $my_reduceri all i get is an empty array: array(0) { } even though there should actually be some results... any idea where i am wrong (in the query)?
thank you
Did you declared global $wpdb; before using this query?