送信時にmysqlクエリのwhereステートメントとなる値が含まれる場合と含まれない場合がある4つのドロップダウンメニューがあります。$_POST['dropdownitem'] が空でない場合に where ステートメントを挿入する方法を見つけたいと思います。以下のブロックでは、基本的に $_POST を含むものはすべて存在する場合と存在しない場合があります。
$select = dbz( )
->select( )
->from( array( 'l' => 'logs' ) )
->joinLeft( array( 'd' => 'dealers' ), 'l.dealerID = d.id' )
->joinLeft( array( 'p' => 'prospects' ), 'l.dealerID = p.id', array( 'id', 'name AS pname' ) )
->where( 'l.id = ?', $currentUser[ 'id' ] )
->where( 'l.dealerId = ?', $_POST[ 'dealerid' ] )
->where( 'logData LIKE ?', '%' . $_POST[ 'activitytype' ] . '%' );
->where( 'logTime >= ?', $today )
->where( 'logTime < ?', strtotime( $tomorrow ) );
$userLogs = dbz( )->fetchAll( $select );