Announcement

Collapse
No announcement yet.

Count Records INCLUDING Marked For Deletion

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Count Records INCLUDING Marked For Deletion

    I want to count the number of records created on a certain date, but this number MUST include those marked for deletion

    Code:
    $count = $this->getEntityManager()->getRepository($entityType)->where([
        'createdAt*' => date("Y-m-d %:%:%")
    ])->count();
    The above code only counts the non-deleted ones.

    How can I take into account those records which have been deleted?

  • #2
    Hello,
    by PDO
    a sample.. you need use select count
    PHP Code:
    $pdo $this->getEntityManager()->getPDO();
            
    $sql "DELETE FROM scheduled_job_log_record WHERE status='Success';DELETE FROM job WHERE status='Success'";
            
    $sth $pdo->prepare($sql);
            
    $sth->execute(); 

    Comment


    • #3
      item nice one, thank you - I’ll try this tomorrow!

      Comment


      • #4
        This should work out:

        PHP Code:
        $count $entityManager->where($clause)->count(['withDeleted' => true]); 

        Comment


        • #5
          Originally posted by yurikuzn View Post
          This should work out:

          PHP Code:
          $count $entityManager->where($clause)->count(['withDeleted' => true]); 
          yuri thank you - this looks like a nicer solution but its useful to know about both methods.

          Comment

          Working...
          X