jordanwb Posted June 5, 2008 Share Posted June 5, 2008 I have a settings table. In said table there will always be one row. I added a two bit Binary field to my table. When I went to edit the existing row, in the binary field (this is phpMyAdmin) it says "\0\0". Now I want 2 in the field so in binary that's 10, so I type 10, click Go, and it changes to \0\0, I edit the row again and type 2. Changes to \0\0 again. How do I put a value into a binary field? Quote Link to comment Share on other sites More sharing options...
fenway Posted June 5, 2008 Share Posted June 5, 2008 you can & it with a bitmask. Quote Link to comment Share on other sites More sharing options...
jordanwb Posted June 6, 2008 Author Share Posted June 6, 2008 ??? Quote Link to comment Share on other sites More sharing options...
fenway Posted June 6, 2008 Share Posted June 6, 2008 See here. Quote Link to comment Share on other sites More sharing options...
jordanwb Posted June 8, 2008 Author Share Posted June 8, 2008 Um okay. Alls I want to do is store a 0, 1, or a 2. I assume that the Binary type is not the right one to use. Quote Link to comment Share on other sites More sharing options...
fenway Posted June 10, 2008 Share Posted June 10, 2008 Um okay. Alls I want to do is store a 0, 1, or a 2. I assume that the Binary type is not the right one to use. You can use binary... those are numbers, too. Quote Link to comment Share on other sites More sharing options...
jordanwb Posted June 10, 2008 Author Share Posted June 10, 2008 Yeah but that page that was quoted didn't show me how to put a number into the field. All it showed me was how to do bitwise operations. Or maybe I missing something that I'm not seeing. Quote Link to comment Share on other sites More sharing options...
fenway Posted June 10, 2008 Share Posted June 10, 2008 Yeah but that page that was quoted didn't show me how to put a number into the field. All it showed me was how to do bitwise operations. Or maybe I missing something that I'm not seeing. Bitmasks can be used to toggle bit fields. Quote Link to comment Share on other sites More sharing options...
jordanwb Posted June 10, 2008 Author Share Posted June 10, 2008 Ok. ??? So If I want 2 I'd have to do what? 2 & 2? That's sound kinda stupid to get a two bit value. Quote Link to comment Share on other sites More sharing options...
fenway Posted June 11, 2008 Share Posted June 11, 2008 So If I want 2 I'd have to do what? That depends on what you have right now... you want to toggle, right? If not, forget bitmasks. Quote Link to comment Share on other sites More sharing options...
jordanwb Posted June 11, 2008 Author Share Posted June 11, 2008 I don't have anything. I added the field to my table and I'm trying to figure out how to but a two bit unsigned integer into it. Maybe I'd be better off with TinyInt(1). Quote Link to comment Share on other sites More sharing options...
fenway Posted June 12, 2008 Share Posted June 12, 2008 I thought you wanted to toggle between b10 and b00. Quote Link to comment Share on other sites More sharing options...
jordanwb Posted June 12, 2008 Author Share Posted June 12, 2008 Well I wanted to hold a value between 0 and 2 (inclusive), and I wanted to take up as little space as possible. Quote Link to comment Share on other sites More sharing options...
fenway Posted June 13, 2008 Share Posted June 13, 2008 Then I suppose TINYINT will do (UNSIGNED, probably). Quote Link to comment 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.