0

I have a bit type column in database table. First I was having problem saving field which solved by this question Laravel 4.2 BIT datatype issue

But now when I retrieve data i a getting that bit type field as {}.

"active": {}

Please help me if anyone has solution.

Edit: Sorry, the problem is while creating object.

I have a "schedule" table in which I have "active" field which is BIT. When I create new Schedule using laravel eloquent, returned object has 'active' field as emptystring {}, No matter bit value is 0 or 1.

$schedule = Schedule::create($input);

returns

{
      "active": {},
      "cityId": 84,
      "eventdate": "2015-09-01T00:00:00+05:30",
      "updatedon": "2015-09-15 16:53:48",
      "createdon": "2015-09-15 16:53:48"
}
Community
  • 1
  • 1
sp11
  • 323
  • 1
  • 3
  • 6

1 Answers1

0

I have faced same problem, i have done like this.

Normally i have retrieve like this but failed to get the email data.In this case email datatype is BIT.

$query = "SELECT Username, email FROM users";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
print_r($row);

after that i have tried like this and it's working fine for me.

$query = "SELECT Username, CAST(email AS unsigned integer) AS emailid FROM users";
RaMeSh
  • 3,330
  • 2
  • 19
  • 31