Bitwise and MySQL for Pagination

I have a table with a field name department, this field contains bitwise values.

I want to check if the department field is inside the departments allowed to access by the user. But doing the following doesn't work:

$this->Paginator->settings = array(
    'conditions' => array('department & ' => $this->Session->read('User.departments')),
    'limit'      => 10,
    'order'      => 'date DESC',
);

What can I do to solve it?

Answers


I think your syntax is incorrect. See Mysql Bitwise operations and filter

Try this:

'conditions' => array(
   "ModelName.department & '" . $this->Session->read('User.departments') . "'"
)

Need Your Help

MPMoviePlayerController doesn't play newly saved video file

iphone ios video uiimagepickercontroller mpmovieplayercontroller

I'm using an imagePickerController to record video. In the imagePickerController:didFinishPickingMediaWithInfo: function I'm trying to set the video to a previously defined MPMoviePlayerController:...

Combine multiple variables to send as a udp packet

c++ variables udp

I need to send a packet of data over a UDP connection in C++. The first message I need to send is built up of two 32 bit integers and a 64 bit integer. What is the best way to combine multiple vari...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.