Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7776571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:55:09+00:00 2026-06-01T17:55:09+00:00

So, I must say that I am completely new to symfony, i’ve been using

  • 0

So, I must say that I am completely new to symfony, i’ve been using it for a total of about 4 days now but I’ve come quite far in my knowledge thus far…

I was recently put onto a project to add a new feature, so I checked out the repo via git and created the new entity and the crud to begin working on it… It’s worth noting that this system is using the PDO MySQL drivers.

In my doctrine config yml for my entity I have:

Ecs\CrmBundle\Entity\TimeClock:
type: entity
table: null
fields:
    id:
        type: integer
        id: true
        generator:
            strategy: AUTO
    in1:
        type: datetime
    out1:
        type: datetime
    in2:
        type: datetime
    out2:
        type: datetime
    totaltime:
        type: string
    daydate:
        type: datetime
manyToOne:
    noteBy:
        targetEntity:  Ecs\AgentManagerBundle\Entity\User
lifecycleCallbacks: {  }

This is for a timeclock for our employees to use… Then in my timeclock controller, in the index() function what I need to do is search the database for entries that are this payperiod but only for the agent that is logged in…

So lets say for example that i’ve already written the code for $start and $end that will hold dates in the datetime format… so like:

$start = "2012-03-24 00:00:00" and $end = "2012-03-31 23:59:59" respectively..

The code I currently have that is pulling all entries for the agent logged in is:

public function indexAction()
{
    $em = $this->getDoctrine()->getEntityManager();
    $user = $this->get('security.context')->getToken()->getUser();
    // date format: YYYY-MM-DD HH:MM:SS
    $entities = $em->getRepository('EcsCrmBundle:TimeClock')->findBy(array('noteBy' => $user->getid()));

    return $this->render('EcsCrmBundle:TimeClock:index.html.twig', array(
        'entities' => $entities,
    ));
}

So, how do I expand upon $entities to include narrowing it down with $start and $end?

[EDIT]

I’ve done a little research and ive re-written the indexAction function a little bit..

public function indexAction()
{
    $em = $this->getDoctrine()->getEntityManager();
    $user = $this->get('security.context')->getToken()->getUser();
    // date format: YYYY-MM-DD HH:MM:SS
    $today = time();
    if (date('l') == "Saturday") {
        $end = date('Y-m-d ')."23:59:59";
    } else {
        $end = date('Y-m-d ', strtotime('next_saturday', $today))."23:59:59";
    }
    $start = date('Y-m-d H:i:s', strtotime('last_sunday', $today));
    $entities = $em->getRepository('EcsCrmBundle:TimeClock');
    echo $user->getid();
    $query = $entities->createQueryBuilder('tc')
        ->where('tc.noteBy = :user')
        ->where('tc.daydate <= :end')
        ->where('tc.daydate >= :start')
        ->setParameter('user', $user->getid())
        ->setParameter('end', $end)
        ->setParameter('start', $start)
        ->getQuery();
    $entities = $query->getResult();

    return $this->render('EcsCrmBundle:TimeClock:index.html.twig', array(
        'entities' => $entities,
    ));
}

But now when I run it, it gives me this:

Invalid parameter number: number of bound variables does not match number of tokens but doesn’t tell me where the problem is… If i remove the 2 where(tc.daydate) and the corresponding setParameter functions, it returns the expected results minus the filtering on the date they were entered.. any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:55:10+00:00Added an answer on June 1, 2026 at 5:55 pm

    I figured it out after searching and searching and coming up with not much of anything… The problem, as i’m guessing was too many where commands…

     public function indexAction()
    {
        $em = $this->getDoctrine()->getEntityManager();
        $user = $this->get('security.context')->getToken()->getUser();
        // date format: YYYY-MM-DD HH:MM:SS
        $today = time();
        if (date('l') == "Saturday") {
            $end = date('Y-m-d ')."23:59:59";
        } else {
            $end = date('Y-m-d ', strtotime('next_saturday', $today))."23:59:59";
        }
        $start = date('Y-m-d H:i:s', strtotime('last_sunday', $today));
        $entities = $em->getRepository('EcsCrmBundle:TimeClock');
        echo $user->getid();
        $query = $entities->createQueryBuilder('tc')
            ->where('tc.noteBy = :user')
            ->andWhere('tc.daydate <= :end')
            ->andWhere('tc.daydate >= :start')
            ->setParameter('user', $user->getid())
            ->setParameter('end', $end)
            ->setParameter('start', $start)
            ->getQuery();
        $entities = $query->getResult();
    
        return $this->render('EcsCrmBundle:TimeClock:index.html.twig', array(
            'entities' => $entities,
        ));
    }
    

    changing the 2 for the daydate to andWhere fixed the problem completely..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First I must say that I'm not good at English and completely new to
I must say that so far, I've probably just been darn lucky in that
Firstly, I must say that the version of Lucene.NET we are using is not
First of all, I must say that I am quite new to the API
Why does MISRA 14.5 say that the continue statement must not be used?
Well, I must say , I am lost with a feeling that the operation
Suppose I have a method that must return an object (say from a database
Say I want to define that an URI such as: myapp://path/to/what/i/want?d=This%20is%20a%20test must be handled
I know that somewhere in the history of the internet this must have been
I am a beginner in Knockout and I must say I often get confused

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.