I am getting an error when I loop from a query builder in phpReference - What does this error mean in PHP?How do I use PHP to get the current year?Detecting request type in PHP (GET, POST, PUT or DELETE)Deleting an element from an array in PHPHow do I get PHP errors to display?How do I get a YouTube video thumbnail from the YouTube API?How to get the client IP address in PHPGet the full URL in PHPHow to fix “Headers already sent” error in PHPReference - What does this error mean in PHP?Doctrine DBAL setParameter() with array value

Runaway-argument error message when line break occurs inside argument of a macro

What do you do if you have developments on your paper during the long peer review process?

Social leper versus social leopard

Which museums have artworks of all four ninja turtles' namesakes?

Where are they calling from?

Why there so many pitch control surfaces on the Piaggio P180 Avanti?

What was the deeper meaning of Hermione wanting the cloak?

In a jam session, when asked which key my non-transposing instrument (like a violin) is in, what do I answer?

Figuring out the frequency components using FFT

Is there any actual security benefit to restricting foreign IPs?

As an employer, can I compel my employees to vote?

Can planetary bodies have a second axis of rotation?

Compactness Theorem- Why not Counterexample?

Is Zack Morris's 'time stop' ability in "Saved By the Bell" a supernatural ability?

Manager encourages me to take day of sick leave instead of PTO, what's in it for him?

Escape the labyrinth!

Is there any reason nowadays to use a neon indicator lamp instead of an LED?

Why does NASA publish all the results/data it gets?

Is It Possible to Have Different Sea Levels, Eventually Causing New Landforms to Appear?

Understanding an example in Golan's "Linear Algebra"

How to make interviewee comfortable interviewing in lounge chairs

To this riddle, I invite

Hilbert's hotel, why can't I repeat it infinitely many times?

Hiking with a mule or two?



I am getting an error when I loop from a query builder in php


Reference - What does this error mean in PHP?How do I use PHP to get the current year?Detecting request type in PHP (GET, POST, PUT or DELETE)Deleting an element from an array in PHPHow do I get PHP errors to display?How do I get a YouTube video thumbnail from the YouTube API?How to get the client IP address in PHPGet the full URL in PHPHow to fix “Headers already sent” error in PHPReference - What does this error mean in PHP?Doctrine DBAL setParameter() with array value






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I build a query which does return results since i var dump the objects, however, when I loop through the results, I get an error during the loop stage.



I have tried to looking on online as to why I am getting the error, including the php documentation.



Here is my querybuilder.



/** @var QueryBuilder $qb */
$qb = $repository->createQueryBuilder('i');
$qb->select('j.fund_code', 'j.amount', 'i.source_code',
'i.keyword', 'i.created_at', 'i.status', 'g.transaction_id')
->join('i.gateway_response', 'g')
->join('i.items', 'j')
->Where("i.status = :status")
->andWhere($qb->expr()->between('i.created_at',
':starts_at', ':ends_at'))
->setParameter('status', 2)
->setParameter('starts_at', $startsAt,
DoctrineDBALTypesType::DATETIME)
->setParameter('ends_at', $endsAt,
DoctrineDBALTypesType::DATETIME)
;

$query = $qb->getQuery();
$results = $query->getResult();
$resultCount = count($results);
var_dump($results);


Here is my If fucntion with a foreach loop.



 if($resultCount > 0) {
foreach($results as $holdTran)

$status = $holdTran->getStatus();




$output->writeln($resultCount . ': Transactions on Hold');
$output->writeln($status);


$mailer = $this->getContainer()->get('mailer');
$message = new Swift_Message();
$message
->setSubject('Daily Giving Report')
->setFrom('chris2kus31@gmail.com')
->setTo('cmoreno@kcm.org')
->setContentType("text/html")
->setBody($this->getContainer()->get('templating')-
>render('@Giving/Default/givingReport.html.twig',
[
'resultCount' => $resultCount,
'status'=> $status
])

);


Here is the error I am getting in return




Fatal error: Call to a member function getStatus() on array




What I am trying to do is do a query, get the results that will pass the objects to a twig template



varDump Resutl



array(1) 
[0] =>
array(7)
'fund_code' =>
string(4) "K100"
'amount' =>
double(20)
'source_code' =>
NULL
'keyword' =>
NULL
'created_at' =>
class DateTime#675 (3)
public $date =>
string(26) "2019-03-26 08:03:20.000000"
public $timezone_type =>
int(3)
public $timezone =>
string(15) "America/Chicago"

'status' =>
int(2)
'transaction_id' =>
string(12) "000035772641"











share|improve this question


























  • Can you show us the var_dump result?

    – Elanochecer
    Mar 28 at 14:59











  • $holdTran is an array, not an object, so getStatus() won't work. var_dump($holdTran); to see exactly what it holds and how to get the data you want.

    – aynber
    Mar 28 at 14:59











  • Possible duplicate of Reference - What does this error mean in PHP?

    – aynber
    Mar 28 at 15:00











  • @elanochecer, i added the vardump result

    – Chris2kus
    Mar 28 at 15:03











  • @Jesus2kus just replace $status = $holdTran->getStatus(); with $status = $holdTran['status'];

    – Elanochecer
    Mar 28 at 15:05

















0















I build a query which does return results since i var dump the objects, however, when I loop through the results, I get an error during the loop stage.



I have tried to looking on online as to why I am getting the error, including the php documentation.



Here is my querybuilder.



/** @var QueryBuilder $qb */
$qb = $repository->createQueryBuilder('i');
$qb->select('j.fund_code', 'j.amount', 'i.source_code',
'i.keyword', 'i.created_at', 'i.status', 'g.transaction_id')
->join('i.gateway_response', 'g')
->join('i.items', 'j')
->Where("i.status = :status")
->andWhere($qb->expr()->between('i.created_at',
':starts_at', ':ends_at'))
->setParameter('status', 2)
->setParameter('starts_at', $startsAt,
DoctrineDBALTypesType::DATETIME)
->setParameter('ends_at', $endsAt,
DoctrineDBALTypesType::DATETIME)
;

$query = $qb->getQuery();
$results = $query->getResult();
$resultCount = count($results);
var_dump($results);


Here is my If fucntion with a foreach loop.



 if($resultCount > 0) {
foreach($results as $holdTran)

$status = $holdTran->getStatus();




$output->writeln($resultCount . ': Transactions on Hold');
$output->writeln($status);


$mailer = $this->getContainer()->get('mailer');
$message = new Swift_Message();
$message
->setSubject('Daily Giving Report')
->setFrom('chris2kus31@gmail.com')
->setTo('cmoreno@kcm.org')
->setContentType("text/html")
->setBody($this->getContainer()->get('templating')-
>render('@Giving/Default/givingReport.html.twig',
[
'resultCount' => $resultCount,
'status'=> $status
])

);


Here is the error I am getting in return




Fatal error: Call to a member function getStatus() on array




What I am trying to do is do a query, get the results that will pass the objects to a twig template



varDump Resutl



array(1) 
[0] =>
array(7)
'fund_code' =>
string(4) "K100"
'amount' =>
double(20)
'source_code' =>
NULL
'keyword' =>
NULL
'created_at' =>
class DateTime#675 (3)
public $date =>
string(26) "2019-03-26 08:03:20.000000"
public $timezone_type =>
int(3)
public $timezone =>
string(15) "America/Chicago"

'status' =>
int(2)
'transaction_id' =>
string(12) "000035772641"











share|improve this question


























  • Can you show us the var_dump result?

    – Elanochecer
    Mar 28 at 14:59











  • $holdTran is an array, not an object, so getStatus() won't work. var_dump($holdTran); to see exactly what it holds and how to get the data you want.

    – aynber
    Mar 28 at 14:59











  • Possible duplicate of Reference - What does this error mean in PHP?

    – aynber
    Mar 28 at 15:00











  • @elanochecer, i added the vardump result

    – Chris2kus
    Mar 28 at 15:03











  • @Jesus2kus just replace $status = $holdTran->getStatus(); with $status = $holdTran['status'];

    – Elanochecer
    Mar 28 at 15:05













0












0








0








I build a query which does return results since i var dump the objects, however, when I loop through the results, I get an error during the loop stage.



I have tried to looking on online as to why I am getting the error, including the php documentation.



Here is my querybuilder.



/** @var QueryBuilder $qb */
$qb = $repository->createQueryBuilder('i');
$qb->select('j.fund_code', 'j.amount', 'i.source_code',
'i.keyword', 'i.created_at', 'i.status', 'g.transaction_id')
->join('i.gateway_response', 'g')
->join('i.items', 'j')
->Where("i.status = :status")
->andWhere($qb->expr()->between('i.created_at',
':starts_at', ':ends_at'))
->setParameter('status', 2)
->setParameter('starts_at', $startsAt,
DoctrineDBALTypesType::DATETIME)
->setParameter('ends_at', $endsAt,
DoctrineDBALTypesType::DATETIME)
;

$query = $qb->getQuery();
$results = $query->getResult();
$resultCount = count($results);
var_dump($results);


Here is my If fucntion with a foreach loop.



 if($resultCount > 0) {
foreach($results as $holdTran)

$status = $holdTran->getStatus();




$output->writeln($resultCount . ': Transactions on Hold');
$output->writeln($status);


$mailer = $this->getContainer()->get('mailer');
$message = new Swift_Message();
$message
->setSubject('Daily Giving Report')
->setFrom('chris2kus31@gmail.com')
->setTo('cmoreno@kcm.org')
->setContentType("text/html")
->setBody($this->getContainer()->get('templating')-
>render('@Giving/Default/givingReport.html.twig',
[
'resultCount' => $resultCount,
'status'=> $status
])

);


Here is the error I am getting in return




Fatal error: Call to a member function getStatus() on array




What I am trying to do is do a query, get the results that will pass the objects to a twig template



varDump Resutl



array(1) 
[0] =>
array(7)
'fund_code' =>
string(4) "K100"
'amount' =>
double(20)
'source_code' =>
NULL
'keyword' =>
NULL
'created_at' =>
class DateTime#675 (3)
public $date =>
string(26) "2019-03-26 08:03:20.000000"
public $timezone_type =>
int(3)
public $timezone =>
string(15) "America/Chicago"

'status' =>
int(2)
'transaction_id' =>
string(12) "000035772641"











share|improve this question
















I build a query which does return results since i var dump the objects, however, when I loop through the results, I get an error during the loop stage.



I have tried to looking on online as to why I am getting the error, including the php documentation.



Here is my querybuilder.



/** @var QueryBuilder $qb */
$qb = $repository->createQueryBuilder('i');
$qb->select('j.fund_code', 'j.amount', 'i.source_code',
'i.keyword', 'i.created_at', 'i.status', 'g.transaction_id')
->join('i.gateway_response', 'g')
->join('i.items', 'j')
->Where("i.status = :status")
->andWhere($qb->expr()->between('i.created_at',
':starts_at', ':ends_at'))
->setParameter('status', 2)
->setParameter('starts_at', $startsAt,
DoctrineDBALTypesType::DATETIME)
->setParameter('ends_at', $endsAt,
DoctrineDBALTypesType::DATETIME)
;

$query = $qb->getQuery();
$results = $query->getResult();
$resultCount = count($results);
var_dump($results);


Here is my If fucntion with a foreach loop.



 if($resultCount > 0) {
foreach($results as $holdTran)

$status = $holdTran->getStatus();




$output->writeln($resultCount . ': Transactions on Hold');
$output->writeln($status);


$mailer = $this->getContainer()->get('mailer');
$message = new Swift_Message();
$message
->setSubject('Daily Giving Report')
->setFrom('chris2kus31@gmail.com')
->setTo('cmoreno@kcm.org')
->setContentType("text/html")
->setBody($this->getContainer()->get('templating')-
>render('@Giving/Default/givingReport.html.twig',
[
'resultCount' => $resultCount,
'status'=> $status
])

);


Here is the error I am getting in return




Fatal error: Call to a member function getStatus() on array




What I am trying to do is do a query, get the results that will pass the objects to a twig template



varDump Resutl



array(1) 
[0] =>
array(7)
'fund_code' =>
string(4) "K100"
'amount' =>
double(20)
'source_code' =>
NULL
'keyword' =>
NULL
'created_at' =>
class DateTime#675 (3)
public $date =>
string(26) "2019-03-26 08:03:20.000000"
public $timezone_type =>
int(3)
public $timezone =>
string(15) "America/Chicago"

'status' =>
int(2)
'transaction_id' =>
string(12) "000035772641"








php arrays symfony doctrine query-builder






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 15:02







Chris2kus

















asked Mar 28 at 14:54









Chris2kusChris2kus

4710 bronze badges




4710 bronze badges















  • Can you show us the var_dump result?

    – Elanochecer
    Mar 28 at 14:59











  • $holdTran is an array, not an object, so getStatus() won't work. var_dump($holdTran); to see exactly what it holds and how to get the data you want.

    – aynber
    Mar 28 at 14:59











  • Possible duplicate of Reference - What does this error mean in PHP?

    – aynber
    Mar 28 at 15:00











  • @elanochecer, i added the vardump result

    – Chris2kus
    Mar 28 at 15:03











  • @Jesus2kus just replace $status = $holdTran->getStatus(); with $status = $holdTran['status'];

    – Elanochecer
    Mar 28 at 15:05

















  • Can you show us the var_dump result?

    – Elanochecer
    Mar 28 at 14:59











  • $holdTran is an array, not an object, so getStatus() won't work. var_dump($holdTran); to see exactly what it holds and how to get the data you want.

    – aynber
    Mar 28 at 14:59











  • Possible duplicate of Reference - What does this error mean in PHP?

    – aynber
    Mar 28 at 15:00











  • @elanochecer, i added the vardump result

    – Chris2kus
    Mar 28 at 15:03











  • @Jesus2kus just replace $status = $holdTran->getStatus(); with $status = $holdTran['status'];

    – Elanochecer
    Mar 28 at 15:05
















Can you show us the var_dump result?

– Elanochecer
Mar 28 at 14:59





Can you show us the var_dump result?

– Elanochecer
Mar 28 at 14:59













$holdTran is an array, not an object, so getStatus() won't work. var_dump($holdTran); to see exactly what it holds and how to get the data you want.

– aynber
Mar 28 at 14:59





$holdTran is an array, not an object, so getStatus() won't work. var_dump($holdTran); to see exactly what it holds and how to get the data you want.

– aynber
Mar 28 at 14:59













Possible duplicate of Reference - What does this error mean in PHP?

– aynber
Mar 28 at 15:00





Possible duplicate of Reference - What does this error mean in PHP?

– aynber
Mar 28 at 15:00













@elanochecer, i added the vardump result

– Chris2kus
Mar 28 at 15:03





@elanochecer, i added the vardump result

– Chris2kus
Mar 28 at 15:03













@Jesus2kus just replace $status = $holdTran->getStatus(); with $status = $holdTran['status'];

– Elanochecer
Mar 28 at 15:05





@Jesus2kus just replace $status = $holdTran->getStatus(); with $status = $holdTran['status'];

– Elanochecer
Mar 28 at 15:05












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55400657%2fi-am-getting-an-error-when-i-loop-from-a-query-builder-in-php%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55400657%2fi-am-getting-an-error-when-i-loop-from-a-query-builder-in-php%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript