ToonMariner Posted November 30, 2009 Share Posted November 30, 2009 HI peeps, Stumped with this one... Have this query <?php $qry = " SELECT `messages`.`message_id` AS `messageID` , `users`.`username` AS `from` , `textsmall`.`text` AS `subject` , DATE_FORMAT(`messages`.`date` , '%W the %D of %M %Y at %l:%i %p') AS `messageDate` , `textfull`.`text` AS `message` , `messages`.`status` AS `status` FROM `messages` LEFT JOIN `textsmall` ON `textsmall`.`text_id` = `messages`.`subject` LEFT JOIN `textfull` ON `textfull`.`text_id` = `messages`.`text` LEFT JOIN `users` ON `users`.`user_id` = `messages`.`from` WHERE `messages`.`message_id` = :mssgID AND 0 = ( IF( `messages`.`to` = :userID , `messages`.`status` & :toDelete , `messages`.`status` & :fromDelete ) ) AND ( `messages`.`to` = :userID OR `messages`.`from` = :userID ) "; echo 'Mssg: ' . $mssgID . ' User: ' . $_SESSION['user_id'] . ' ToDel: ' . TO_DELETE . ' FromDel: ' . FROM_DELETE; $mssg = $this->prepare ( $qry ); $mssg->bindValue ( ':mssgID' , $mssgID , PDO::PARAM_INT ); $mssg->bindValue ( ':userID' , $_SESSION['user_id'] , PDO::PARAM_INT ); $mssg->bindValue ( ':toDelete' , TO_DELETE , PDO::PARAM_INT ); $mssg->bindValue ( ':fromDelete' , FROM_DELETE , PDO::PARAM_INT ); $mssg->execute (); $arr = $mssg->fetchAll ( PDO::FETCH_ASSOC ); if ( count ( $arr ) == 1 ) { return $arr; } ?> this runs in a method (hence the return)... Now this works fine on dev box AND when run through phpmyadmin on the live box but NOT when run through code. Is there anything anyone can suggest as to why this could be so? Any help much appreciated... Quote Link to comment https://forums.phpfreaks.com/topic/183479-pdo-query-not-working-on-live-box/ Share on other sites More sharing options...
ToonMariner Posted November 30, 2009 Author Share Posted November 30, 2009 Update on this... If I remove the conditional AND 0 = ( IF( `messages`.`to` = :userID , `messages`.`status` & :toDelete , `messages`.`status` & :fromDelete ) ) the query runs sucessfuly... Can anyone suggest why running the query through code with the offending portion of the query kept in? Quote Link to comment https://forums.phpfreaks.com/topic/183479-pdo-query-not-working-on-live-box/#findComment-968515 Share on other sites More sharing options...
fenway Posted December 1, 2009 Share Posted December 1, 2009 Echo the actual queries. Quote Link to comment https://forums.phpfreaks.com/topic/183479-pdo-query-not-working-on-live-box/#findComment-968880 Share on other sites More sharing options...
ToonMariner Posted December 3, 2009 Author Share Posted December 3, 2009 That is the query run - the Values bound are: mssgID ( the message id ) = 1 - this message exists. userID = 1, toDelete = 4 fromDelete = 8. the status on message one is 3 so the bitwise comparison should return 0 hence the the message SHOULD be selected. Quote Link to comment https://forums.phpfreaks.com/topic/183479-pdo-query-not-working-on-live-box/#findComment-970186 Share on other sites More sharing options...
fenway Posted December 4, 2009 Share Posted December 4, 2009 Maybe someone else can help -- I don't feel like interpolating the variables myself when a simple echo() will suffice. Quote Link to comment https://forums.phpfreaks.com/topic/183479-pdo-query-not-working-on-live-box/#findComment-971244 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.