[TYPO3-mvc] Cannot cast object of type "Tx_Extbase_Persistence_QueryResult" to string.

Claus Due claus at wildside.dk
Mon Jun 13 11:10:16 CEST 2011


Hi Johannes,

The function below looks good; the problem must stem from accessing the return value (a QueryResult) directly without iterating or using ->getFirst() - that would cause the error message.

Could this be because of something done in Fluid using that QueryResult? If so, it should help if you either iterate the QueryResult or use {queryResult.first} (I believe - can't remember wether the {var.first} is the proper way of getting the first record available from Fluid...

--

Kind regards

Claus Due
Developer

--
Wildside A/S
Katrinebjergvej 113, DK-8200 Århus N
tlf. 86 12 64 65
http://www.wildside.dk

Wildside er Danmarks mest kreative TYPO3-hus. Vi griber dine behov, 
tanker og sjove ideer og skaber unikke kommunikationsløsninger og 
websites. Vi tager hånd om hele processen fra idé til færdigt produkt, 
og vi hjælper dig, når løsningen går i luften. 

--

Nyt produkt: Open Source webshops baseret på Magento Commerce

http://www.wildside.dk/hvad-kan-vi/magento/

On Jun 13, 2011, at 10:19 AM, Johannes C. Schulz - EnzephaloN IT-Solutions wrote:

> Hi there!
> 
> 
> 
> Today I have a problem with the error-message:
> 
> Cannot cast object of type "Tx_Extbase_Persistence_QueryResult" to string.
> 
> 
> 
> I think something in my repository is wrong, but I didn't find it:
> 
> 
> 
> class Tx_EnzTeaserlist_Domain_Repository_TeaseritemRepository extends
> Tx_Extbase_Persistence_Repository {
> 
> 
> 
>      public function givemelist($category,$order,$type,$storage){
> 
>            $orderings = array($type => $order == 'ORDER_ASCENDING' ? 
> 
> 
> Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING : 
> 
> 
> Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING);
> 
>            if(!empty($storage)) {
> 
>                  $pid = $storage;
> 
>            }else{
> 
>                  $pid = t3lib_div::_GP('id');
> 
>            }
> 
> 
> 
>            $query = $this->createQuery();
> 
> 
> 
>                  $pidsearch = array();
> 
>                  if (!is_array($pid)) {
> 
>                        $pidsearch =
> $query->logicalOr(array($query->equals('teaseritem.pid',$pid)));
> 
>                  }
> 
>                  else {
> 
>                        $pidsearch =
> $query->logicalOr(array($query->in('teaseritem.pid',$pid)));
> 
>                  }
> 
> 
> 
>        if(!empty($pidsearch))
> $query->matching($query->logicalAnd($pidsearch));
> 
>      $query->setOrderings($orderings);
> 
>      return $query->execute();
> 
>      }
> 
> }
> 
> 
> 
> Can somebody help me please?
> 
> 
> 
> Best regards
> 
> Johannes
> 
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc



More information about the TYPO3-project-typo3v4mvc mailing list