|If you insert into the database using a value of zero, nothing is inserted into the database at all for that field.|
$first_name = 'Rob';
$f1 = '1';
$f2 = '0';
$dbLink = new DB();
$aResult = $dbLink->query('INSERT INTO app_data (first_name,f1,f2) VALUES (?,?,?)',$first_name,$f1,$f2);
The table shows:
|Rob |1 | |
|2010-04-01 20:43:41 - In reply to message 1 from Robert Frew|
|That seems to happen with the "BIT" fields and the command line mysql client. |
If you do something like this:
$aRes = $dbLink->query('SELECT * FROM probadita');
you would be able to see something like this:
 => Array
[my_boolean] => 0
 => Array
[my_boolean] => 1
Where 0 == false and 1 == true.
You should insert boolean values as '1' for true and '0' as false (WITH the single quotes).
$aRes = $dbLink->query('INSERT INTO t1 VALUES (?)','0'); // Inserting false
$aRes = $dbLink->query('INSERT INTO t1 VALUES (?)','1'); // Inserting true
|2010-04-01 22:43:12 - In reply to message 2 from Camilo Sperberg|
|Thanks for your reply.|
I thought I was inserting using single quotes as you can see in the example. Is this not the correct way to do this?
Thanks for your help.
|2010-04-01 22:47:28 - In reply to message 2 from Camilo Sperberg|
|Here is what it returns:|
 => Array
[first_name] => Rob
[f1] => 1
|2010-04-01 22:51:07 - In reply to message 2 from Camilo Sperberg|
|Also, if I use the following:|
$f2 = 0; //integer
$f2 = '0'; //string
It enters into the database as 0 just fine. However, I am retrieving these values from a POST form so the numeric values come through as strings.
|2010-04-01 23:29:35 - In reply to message 2 from Camilo Sperberg|
|And last thing... if I don't use your wrapper and I call the mysqli directly, it works just fine using the same variables and information.|
|2010-04-02 15:54:37 - In reply to message 4 from Robert Frew|
|is your MySQL field a BIT field? If not, what field type is it? Which PHP/MySQL version are you using? |