1

私は自分のデータベースから開始または終了する必要があるいくつかのデータを取得しようとしています:

基本的な SQL クエリは次のようになります。

SELECT broadcast.id, broadcast.id_channel, broadcast.start_at, broadcast.real_start_at, broadcast.real_end_at, broadcast.title, broadcast.sended, FROM `broadcast` 
WHERE (
    (broadcast.real_start_at >= :p1 AND broadcast.real_start_at <= :p2) 
    OR 
    (broadcast.real_end_at >= :p3 AND broadcast.real_end_at <= :p4)) 
    AND broadcast.sended=:p5 AND broadcast.id_plurimedia=:p6 
LIMIT 50

推進クエリは次のとおりです。

$broadcastsQuery = BroadcastQuery::create()
        ->limit(20);
        ->condition('cond1', 'broadcast.real_start_at >= ?', $this->date_start, \Criteria::GREATER_EQUAL)
        ->condition('cond2', 'broadcast.real_start_at <= ?', $this->date_end, \Criteria::LESS_EQUAL)
        ->combine(array('cond1', 'cond2'), \Criteria::LOGICAL_AND, 'cond3')
        ->condition('cond4', 'broadcast.real_end_at >= ?', $this->date_start, \Criteria::GREATER_EQUAL)
        ->condition('cond5', 'broadcast.real_end_at <= ?', $this->date_end, \Criteria::LESS_EQUAL)
        ->combine(array('cond4', 'cond5'), \Criteria::LOGICAL_AND, 'cond6')
        ->where(array('cond3', 'cond6'), null, 'OR');
        ->filterBySended(true)
        ->find();

スクリプトを実行すると、次のエラーが発生します。

Unable to execute SELECT statement [SELECT broadcast.id, broadcast.id_channel, broadcast.id_plurimedia, broadcast.id_aedra, broadcast.start_at, broadcast.real_start_at, broadcast.real_end_at, broadcast.title, broadcast.sended, broadcast.date_creation, broadcast.date_edition FROM `broadcast` WHERE ((broadcast.real_start_at >= :p1 AND broadcast.real_start_at <= :p2) AND (broadcast.real_end_at >= :p3 AND broadcast.real_end_at <= :p4)) AND broadcast.sended=:p5 LIMIT 50] [wrapped: Warning: PDOStatement::bindValue() expects parameter 3 to be long, string given in /var/www/projectKI/vendor/propel/propel1/runtime/lib/connection/DebugPDOStatement.php line 114] (500 Internal Server Error)

エラーが発生する理由と、クエリに「OR」ではなく「AND」ステートメントが含まれている理由がよくわかりません。

4

1 に答える 1