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

  • Home
  • SEARCH
  • 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 7032453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:56:16+00:00 2026-05-28T00:56:16+00:00

in my repository i have public function findAllMorosos($date = ‘now’) { $datetime = new

  • 0

in my repository i have

public function findAllMorosos($date = 'now')
{
    $datetime = new \Datetime($date);

    $stmt = $this->getEntityManager()
        ->getConnection()
        ->prepare(self::sql_morosos);

    $stmt->bindValue(':fecha', $datetime, 'datetime');
    if ($stmt->execute()) {
        return $stmt;
    }

    return null;
}

my SQL query is

-- SQL
select p.* from inf_pago p
    join inf_venta v on v.id = p.venta_id
    join inf_cliente c on c.id = v.cliente_id
where p.fecha_pago < ':fecha'
and DATEDIFF(':fecha', p.fecha_pago) >= 30
and p.saldo_por_pagar != 0

when i execute $repository->findAllMorosos() i get empty array (expects 1 row), the query is fine.

when i try:

public function findAllMorosos($fecha = 'now')
{
    $datetime = new \Datetime($fecha);

    $stmt = $this->getEntityManager()
        ->getConnection()
        ->prepare(str_replace(':fecha', $datetime->format('Y-m-d'), self::sql_morosos));
    if ($stmt->execute()) {
        return $stmt;
    }

    return null;
}

works fine.

can explain what is wrong with the bindValue method the documentation and more docs not enough

  • 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-05-28T00:56:16+00:00Added an answer on May 28, 2026 at 12:56 am

    The problem I think is actually in your sql string. Do not wrap the parameter placeholders in quotes. And, I think you need more than one placeholder and binding. Change sql to this:

    where p.fecha_pago < :fecha1
    and DATEDIFF(:fecha2, p.fecha_pago) >= 30
    

    Then, bind this way:

    $stmt->bindValue(':fecha1', $datetime, 'datetime');
    $stmt->bindValue(':fecha2', $datetime, 'datetime');
    

    Note, doctrine uses it’s own statement bindValue implementation which maps the third argument, if it is a string, to a PDO parameter int. Something I did not realize until today 🙂

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

Sidebar

Related Questions

Say I have: public ViewResult List() { IEnumerable<IModel> myList = repository.GetMyList(); if(1 == myList.Count())
We have a public Sonatype Nexus Maven Repository which is a proxy for several
Example I have a repository class (DAL): public class MyRepository : IMyRepository { public
I have a repository class that inherits from a generic implementation: public namespace RepositoryImplementation
I have a Repository Class with the following method... public T Single<T>(Predicate<T> expression) {
I have the following Repository: Public Class PageRepository Private Shared _pages As BLL.PageCollection Shared
I have those maps in my repository. public IQueryable<AwType> GetAwTypes() { return from awt
I've built a Repository that gets user details Public Function GetUserByOpenID(ByVal openid As String)
I have implemented the repository pattern using the following generic interface. public interface IRepository<T>
I have been dealing with this for at least two days now. I don't

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.