Cannot retrieve rows from Zend_Db_Table_Rowset - zend-framework

I have successfully fetched a rowset from my database table unto the view script. I did a var_dump($result) on the view script to confirm. But I am unable to fetch the individual rows to properly display their contents.
<?php
if($this->result)
while($data =$this->result->getRow())
var_dump($data);
I get the error message(truncated..):
Message: No row could be found at position 0
Stack trace:
#0 C:\wamp\www\events\application\views\scripts\event\fetch.phtml(6): Zend_Db_Table_Rowset_Abstract->getRow()
....
....
what am I doing wrong?

I finally got it sorted. The getRow() method apparently does not work with while() loops. I switched to foreach() loop and it's resolved.
Though I would still like to know why the while() loop does not work.

Related

Different values in Variables View than Console View

I´m debugging an IOS application with UITest.
I have tried to get the last index of the table but it gave me an unexpected value like 18446744073709551615.
Then I saw a problem between Variables View and Console View.
In the variables view, at the index value prints -1 but if I execute a 'po' command with the same initialization than the Index variable I got another value as you can check in the picture.
I wish that somebody could help me with this problem or tell me why is it happening.
Regards
It is the same number. -1 = 2^^64 - 1 = 18446744073709551615. You get the last on po.

Empty rows in report when using count function

I am using BIRT reporting with my mongodb datasource. I am trying to COUNT some events. COUNT function gives the correct value but there is big empty space at the end of the page depending upon the count value. If the count value is big then the rest of the page is empty and on the next page same record is coming e.g. :
In this Image the rest of the page is empty and same record is coming on the next pages also. It looks like empty spaces are being printed.
This is how my report looks like :
The COUNT function:
I have tried using SUM also but I get this error when I use SUM function instead of COUNT :
org.eclipse.birt.report.engine.api.EngineException: A BIRT exception occurred. See next exception for more information.
Can not convert the value of True to Double type.
at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1245)
at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1224)
at org.eclipse.birt.report.engine.executor.DataItemExecutor.execute(DataItemExecutor.java:101)
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46)
at org.eclipse.birt.report.engine.internal.executor.emitter.ReportItemEmitterExecutor.execute(ReportItemEmitterExecutor.java:46)
at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.execute(HTMLAbstractLM.java:468)
Please help, thanks in Advance.
I got the issue to this problem. If we select "Hide Detail" Option from the group then this problem go away.

Why this error keeps occurring?

I have inherited some old code. It gets a list of categories from a MySQL database table. I'm tasked with adding multilevel support to them. I've almost got it done, but for some reason it just errors out when I go to try the app in action.
The error is (you can also see it at http://detyams.ru/?cat=1):
Can't use an undefined value as an ARRAY reference at /usr/local/lib/perl5/site_perl/mach/5.18/DBI.pm line 2074, line 2231.
sub catlist
{
my $self=shift;
state $sth=$self->db->prepare(q/SELECT c.cat_id,c.cat_name,COUNT(pn.p_id) as cnt from category c
LEFT JOIN price_new pn ON (pn.cat_id=c.cat_id) GROUP BY pn.cat_id WHERE c.parent_id=?/);
$sth->execute(0);
my #catlist=$sth->fetchall_arrayref({}); # <- this call leads to the failure in the deep of DBI code.
foreach my $item (#catlist)
{
$sth->execute($item->{cat_id});
$item->{children}=$sth->fetchall_arrayref({});
}
return #catlist;
}
I've looked up some examples of using the DBI methods in there (like http://www.perlmonks.org/?node_id=284436#loh), all appear to be in accord with my code.
Oh, so, it just turned out if in case of a query syntax error (WHERE clause was placed in wrong position) fetchall_arrayref() appears to report cryptic errors instead of the underlying problem. Found out by checking server logs.

Cannot update one field at a time with VSTO for Word

When fields are nested, there is a problem.
foreach (Word.Field field in this.Application.ActiveDocument.Fields)
{
field.Update();
text = field.Result.Text;
}
The above code does not work.
The process starts, but winds up in an endless loop or some other process that hangs the system.
Thinking about it, I can surmise that when you update a field, it might have an effect on the fields collection - thus, the loop fails.
Does anyone have any ideas on implementing this?
P.S. I know there is a Document.UpdateFields() method to update ALL fields. However, there are reasons why I cannot use this and need to only update specific field types.
My apologies! I was going to give an example of a nested field but was trying to test some more before sending anyone (Jack) on a goose-chase.
I waited and waited and waited, and after a good 2 or 3 minutes, it finished. After the last field, it crashed with this message:
Object has been deleted.
The error was generated from the following line inside the loop:
string text = field.Code.Text;
The template is being tested on mergefields that are not being found because I am testing without database connectivity. It would be odd, but explainable, that it goes through all the fields and then, at the end of the day, the very OUTER IF field's result is "Error! Reference source not found." But I still don't get why this could happen.
Nor do I understand why looping takes 3 minutes while a call to document.Fields.Update() will do the same thing in about 1 second and NOT result in the error described above.
Again, my apologies. I never considered updating inside a loop would be vastly slower that a call to doc.fields.update().

Problems with empty table view

im trying to write an app that will display a list off lines from a book e.g line 1, line 2 in a table view and you can then select a line to view the corrosponding text.
I've got to the stage where the text should at least appear in the table view(not as far as being able to select it), yet it remains empty.
I used the debugger and was able to find out that there are zero objects in the array used to determine the 'numberOfRowsInSection' and being as this returns zero I think this may explain the problem?
I have pasted up all my code and would really appreciate it if someone has time to skim through it. I know its a big thing to ask but I cant seem to pin point the problem myself.
RootViewController.h --> http://pastie.org/858561
RootViewController.m---> http://pastie.org/858562
BookTestAppDelegate.h ---> http://pastie.org/858566
BookTestAppDelegate.m---> http://pastie.org/858567
LineClass.h----> http://pastie.org/858568
LineClass.m ----> http://pastie.org/858570
SOURCE : http://uploading.com/files/9f5f1249/BookTest.zip/
Thanks guys,
Your sample sqlite database doesn't have table named "animals". But it has table "book". I think you should correct your readLinesFromDatabase method with following SQL statement: select * from book. ;-)