Re: Saving 0 instead of empty string, MySQL
| From: | edA-qa mort-ora-y | Date: | Thu, 12 Jul 2007 16:38:32 +0000 |
| Subject: | Re: Saving 0 instead of empty string, MySQL | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-27660@lists.php.net to get a copy of this message | ||
mysql> desc fs_fortress;
+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| ID | int(11) | NO | PRI | NULL | auto_increment |
| Player | varchar(25) | NO | MUL | NULL | |
| Start | datetime | NO | | NULL | |
| End | datetime | YES | | NULL | |
| Points | int(10) | NO | | 0 | |
| Difficulty | int(2) | NO | | NULL | |
+------------+-------------+------+-----+---------+----------------+
6 rows in set (0.06 sec)
Though, even if the default were some string, since I am explicitly
passing a parameter for this column the default should not be used.
Ken Guest wrote:
> On Wed, Jul 11, 2007 at 08:13:56PM +0200, edA-qa mort-ora-y wrote:
>> I have a problem where the string 0 is being saved to my database rather
>> than the empty string which I am requesting.
>>
>> The code looks like:
>>
>> $es = $db->prepare( "UPDATE fs_fortress SET Player=?, End=?, Points=?
>> WHERE ID=?" );
>> $res = $db->execute( $es, array( $player, mysql_datestr( time() ),
>> $points, $id ) );
>>
>> Where $player is always of string type and works as long as it is
>> non-empty. As soon as $player is an empty string, 0 gets stored.
>>
>
> what are the results of issuing "describe fs_fortress;" ?
> I'm guessing the default value is set to 0 ;->
>
> k.
>
--
edA-qa mort-ora-y
Idea Architect
http://disemia.com/
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc