-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object of class Phalcon\Db\RawValue could not be converted to float #12766
Comments
@Jurigag Could you please take a look |
Yea, can you provide your table schema? |
@Jurigag added in start post |
What happens if you do |
@409H same error on $this->update() line |
Can't reproduce. ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$di = new FactoryDefault();
$di->set(
'db',
function () {
$adapter = new \Phalcon\Db\Adapter\Pdo\Mysql(
[
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'phalcon_test',
'options' => [
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
],
'charset' => 'utf8',
]
);
return $adapter;
}
);
$di->set('modelsMetadata', function (){
$metadata = new Model\MetaData\Apc();
$metadata->setStrategy(new Model\MetaData\Strategy\Annotations());
return $metadata;
});
require "LogsTasks.php";
$model = new LogsTasks;
$model->pid = 1212;
$model->save();
$model->exec_time = 0.1212;
$saved = $model->update();
var_dump($saved); // true Checked on php 7.1.1 but i doubt that on 7.0 there will be difference |
I test this code on Phalcon 3.0.4 - work fine. |
I don't know, you sure you posted full code of your model? Just with this code you posted i don't have error. |
@Jurigag i ran you code and get error
What version you use? |
Oh i forgot use statements:
|
Your example work fine on Phalcon 3.1.1. Thanks! |
Maybe you need to clear metadata? I don't know really. |
Try this example please. <?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
use Phalcon\Di\FactoryDefault;
use Phalcon\Mvc\Model;
class ModelDynamicUpdate extends \Phalcon\Mvc\User\Plugin
{
/**
* @var boolean
*/
protected $dynamicUpdate;
/**
* @param boolean $dynamicUpdate
*/
public function __construct($dynamicUpdate = true)
{
$this->dynamicUpdate = $dynamicUpdate;
}
/**
* @param \Phalcon\Events\Event $event
* @param \Phalcon\Mvc\Model\ManagerInterface $modelsManager
* @param \Phalcon\Mvc\ModelInterface $model
*/
public function afterInitialize(\Phalcon\Events\Event $event, \Phalcon\Mvc\Model\ManagerInterface $modelsManager, \Phalcon\Mvc\ModelInterface $model)
{
$modelsManager->useDynamicUpdate($model, $this->dynamicUpdate);
}
}
$di = new FactoryDefault();
$di->set(
'db', function () {
$adapter = new \Phalcon\Db\Adapter\Pdo\Mysql(
[
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'phalcon_test',
'options' => [
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
],
'charset' => 'utf8',
]
);
return $adapter;
}
);
$di->set('modelsManager', function () {
$eventsManager = new \Phalcon\Events\Manager;
$modelsManager = new Model\Manager;
$eventsManager->attach("modelsManager", new ModelDynamicUpdate(true));
$modelsManager->setEventsManager($eventsManager);
return $modelsManager;
});
require "LogsTasks.php";
$model = new LogsTasks;
$model->pid = 1212;
$model->save();
$model->exec_time = 0.1212;
$saved = $model->update();
var_dump($saved); // true
?> |
Yea, now i see, let me fix it. |
Created PR. |
Fixed in the |
Expected and Actual Behavior
DB Scheme
When update model get error
Details
The text was updated successfully, but these errors were encountered: