PublisherID | StatisticDT | Somecontent |
one | 2012-04-15 00:00:00 | test 15 |
one | 2012-04-16 00:00:00 | test 16 |
one | 2012-04-17 00:00:00 | test 17 |
public function getByPublisherAndDate($publisher_id, \ DateTime $startDt, \ DateTime $endDt)
{
$qb = $ this ->_em->createQueryBuilder()
-> select ( 'p' )
-> from ( '\Model\Entity\PublisherDailyStatistic, ' p ')
->where(' p.publisherid=:publisherid ')
->andWhere(' p.statisticdt>=:startdt ')
->andWhere(' p.statisticdt<=:enddt')
->setParameters(array( "publisherid" =>( int )$publisher_id,
"startdt" =>$startDt,
"enddt" =>$endDt));
return $qb->getQuery()->getResult();
}
* This source code was highlighted with Source Code Highlighter .
array (size=3)
0 =>
object (Model\Entity\PublisherDailyStatistic)[398]
private 'publisherid' => int 1
private 'statisticdt' =>
object ( DateTime )[381]
public 'date' => string '2012-04-15 00:00:00' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Moscow' (length=13)
private 'somecontent' => string 'test 15' (length=7)
1=>
object (Model\Entity\PublisherDailyStatistic)[398]
private 'publisherid' => int 1
private 'statisticdt' =>
object ( DateTime )[381]
public 'date' => string '2012-04-15 00:00:00' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Moscow' (length=13)
private 'somecontent' => string 'test 15' (length=7)
2 =>
object (Model\Entity\PublisherDailyStatistic)[398]
private 'publisherid' => int 1
private 'statisticdt' =>
object ( DateTime )[381]
public 'date' => string '2012-04-15 00:00:00' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Moscow' (length=13)
private 'somecontent' => string 'test 15' (length=7)
* This source code was highlighted with Source Code Highlighter .
array (size=3)
0 =>
array (size=3)
'publisherid' => int 1
'statisticdt' =>
object ( DateTime )[384]
public 'date' => string '2012-04-15 00:00:00' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Moscow' (length=13)
'somecontent' => string 'test 15' (length=7)
1 =>
array (size=3)
'publisherid' => int 1
'statisticdt' =>
object ( DateTime )[384]
public 'date' => string '2012-04-16 00:00:00' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Moscow' (length=13)
'somecontent' => string 'test 16' (length=7)
2 =>
array (size=3)
'publisherid' => int 1
'statisticdt' =>
object ( DateTime )[384]
public 'date' => string '2012-04-17 00:00:00' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Moscow' (length=13)
'somecontent' => string 'test 17' (length=7)
* This source code was highlighted with Source Code Highlighter .
if ($ class ->isIdentifierComposite) {
$id = array();
foreach ($ class ->identifier as $fieldName) {
$id[$fieldName] = isset($ class ->associationMappings[$fieldName])
? $data[$ class ->associationMappings[$fieldName][ 'joinColumns' ][0][ 'name' ]]
: $data[$fieldName];
}
$idHash = implode( ' ' , $id);
} else {
$idHash = isset($ class ->associationMappings[$ class ->identifier[0]])
? $data[$ class ->associationMappings[$ class ->identifier[0]][ 'joinColumns' ][0][ 'name' ]]
: $data[$ class ->identifier[0]];
$id = array($ class ->identifier[0] => $idHash);
}
* This source code was highlighted with Source Code Highlighter .
if ($id[$fieldName] instanceof \ DateTime )
{
$id[$fieldName] = $id[$fieldName]->getTimestamp();
}
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/142221/
All Articles