src/CRUDlex/MySQLData.php
protected function setValuesAndParameters(Entity $entity, QueryBuilder $queryBuilder, $setMethod)
    {
        $formFields = $this->getFormFields();
        $count      = count($formFields);
        for ($i = 0; $i < $count; ++$i) {
            $type  = $this->definition->getType($formFields[$i]);
            $value = $entity->get($formFields[$i]);
            if ($type == 'boolean') {
                $value = $value ? 1 : 0;
            }
            if ($type == 'reference' && is_array($value)) {
                $value = $value['id'];
            }
            $queryBuilder->$setMethod('`'.$formFields[$i].'`', '?');
            $queryBuilder->setParameter($i, $value);
        }
    }
protected function setValuesAndParameters(Entity $entity, QueryBuilder $queryBuilder, $setMethod)
    {
        $formFields = $this->getFormFields();
        $count      = count($formFields);
        for ($i = 0; $i < $count; ++$i) {
            $type  = $this->definition->getType($formFields[$i]);
            $value = $entity->get($formFields[$i]);
            if ($type == 'boolean') {
                $value = $value ? 1 : 0;
            }
            if ($type == 'reference' && is_array($value)) {
                $value = $value['id'];
            }
            $queryBuilder->$setMethod('`'.$formFields[$i].'`', '?');
            $queryBuilder->setParameter($i, $value);
        }
    }
protected function setValuesAndParameters ( Entity $ entity , QueryBuilder $ queryBuilder , $ setMethod ) { $ formFields = $ this -> getFormFields ( ) ; $ count = count ( $ formFields ) ; for ( $ i = 0 ; $ i < $ count ; ++ $ i ) { $ type = $ this -> definition -> getType ( $ formFields [ $ i ] ) ; $ value = $ entity -> get ( $ formFields [ $ i ] ) ; if ( $ type == 'boolean' ) { $ value = $ value ? 1 : 0 ; } if ( $ type == 'reference' && is_array ( $ value ) ) { $ value = $ value [ 'id' ] ; } $ queryBuilder -> $ setMethod ( '`' . $ formFields [ $ i ] . '`' , '?' ) ; $ queryBuilder -> setParameter ( $ i , $ value ) ; } }
Sets the values and parameters of the upcoming given query according
to the entity.

@param Entity $entity
the entity with its fields and values
@param QueryBuilder $queryBuilder
the upcoming query
@param string $setMethod
what method to use on the QueryBuilder: 'setValue' or 'set'
Sets the values and parameters of the upcoming given query according to the entity .