A
A
Andrey2015-12-07 19:12:14
Online shopping
Andrey, 2015-12-07 19:12:14

How to avoid converting data to INT via updateById model?

In general, there was a sku_id (INT) field, I tried to add (42, 43) there when adding to the database. I realized that I need to change the tables to VARCHAR, I did it, but it still returns 0. If I write a number (9999999999999) in the base, the maximum digit of the INT value is (2147483647) although the field is in the VARCHAR value

class shopQdiscountPluginBackendSaveController extends waJsonController {

    public function execute() {
        $product_id = waRequest::post('qdiscount_product_id');
        $qdiscount_id = waRequest::post('qdiscount_id', array());
        $qdiscount_sku = waRequest::post('qdiscount_sku', array());
        $qdiscount_count = waRequest::post('qdiscount_count', array());
        $qdiscount_price = waRequest::post('qdiscount_price', array());


        $qdiscount_model = new shopQdiscountPluginModel();
        $items = array();
        foreach ($qdiscount_id as $key => $id) {
            $item = array(
                'id' => $id,
                'product_id' => $product_id,
                'sku_id' => '55555555555',
                'count' => $qdiscount_count[$key],
                'price' => $qdiscount_price[$key],
            );
            if (empty($item['id'])) {
                $item['id'] = $qdiscount_model->insert($item);
            } else {
                $qdiscount_model->updateById($item['id'], $item);
            }
            $items[] = $item;
        }
        $this->response['items'] = $items;
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question