Why does the getter object return null instead of 0?

I have a field in the database that is tinyint.

Here is the part of the person responsible for this getter:

/**
 * @var integer
 *
 * @ORM\Column(name="showAmounts", type="boolean", nullable=false)
 */
private $showamounts = 1;

/**
 * Get showamounts
 *
 * @return integer
 */
public function getShowamounts()
{
    return $this->showamounts;
}

And if showamounts = 0, then

echo $o->getShowamounts(); // returns "" instead of "0"

When I run getter for int, it works, but I am 100% sure that when I wrote the code (a few months ago), everything worked fine. So my question is: what happened? Maybe because of this, var is in the entity that he defined as logical? I just want to save 0 or 1.

+4
source share
1 answer

Try var_dump your value as:

var_dump($o->getShowamounts());
+4
source

All Articles