Santiago
Santiago

Reputation: 2455

PHP MySQL insert in float(3,1) always get "0" as decimal

I want to insert this value in a FLOAT(3,1) column in my Database:

$sec['votos_rating'] = 5 + ($sec['votos_pos'] * (5 / $sec['votos_total'])) - ($sec['votos_neg'] * (5 / $sec['votos_total']));

But I always get 1.0, 2.0, 3.0, etc...

Do you know what could I be doing wrong?

This was the problem:

    $db->addInteger('votos_rating', $sec['votos_rating']);

I should have used addFloat instead... ;)

Upvotes: 0

Views: 522

Answers (2)

Lusitanian
Lusitanian

Reputation: 11122

Use addFloat($val) to achieve the behavior you desire.

Upvotes: 2

Niclas Larsson
Niclas Larsson

Reputation: 858

Can it be that you using $db->addInteger?

Upvotes: 2

Related Questions