Welcome Guest, Not a member yet? Register   Sign In
trying to use batch_update()
#4

(This post was last modified: 07-29-2020, 08:35 AM by richb201.)

OK. I switched over to this:
        $this->db->where('email', $_SESSION['userid']);
        $this->db->where('campaign', $_SESSION['campaign']);
        $data[] = array(
            'in_sample' => 0
        );
        $this->db->update('employees', $data);

        $this->db->where('in_population', 0);  //ie not excluded
        $sql = "SELECT * FROM employees ORDER BY RAND() LIMIT " . $count;
        $data[] = array(
            'in_sample' => 1
        );
        $query = $this->db->query($sql);
        $this->db->update('employees', $data);

What I am trying to do is first set all OF THE in_sample=0. Then I am trying to pick a random sample of 30 of them and set the chosen rows to in_sample=1. $count=30. 

When I run this I get the following error:
Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0 = Array WHERE `email` = '[email protected]' AND `campaign` = 'Apple'' at line 1

UPDATE `employees` SET 0 = Array WHERE `email` = '[email protected]' AND `campaign` = 'Apple'

Filename: models/MyModel.php

Line Number: 148

Am I calling update incorrectly?
proof that an old dog can learn new tricks
Reply


Messages In This Thread
trying to use batch_update() - by richb201 - 07-28-2020, 04:49 PM
RE: trying to use batch_update() - by ojmichael - 07-28-2020, 08:58 PM
RE: trying to use batch_update() - by qury - 07-29-2020, 01:22 AM
RE: trying to use batch_update() - by richb201 - 07-29-2020, 08:32 AM
RE: trying to use batch_update() - by richb201 - 07-29-2020, 11:16 AM
RE: trying to use batch_update() - by richb201 - 07-29-2020, 02:52 PM
RE: trying to use batch_update() - by richb201 - 07-30-2020, 09:19 AM
RE: trying to use batch_update() - by ojmichael - 07-30-2020, 04:17 PM
RE: trying to use batch_update() - by richb201 - 08-01-2020, 09:02 AM
RE: trying to use batch_update() - by richb201 - 08-02-2020, 05:23 PM
RE: trying to use batch_update() - by ojmichael - 08-03-2020, 05:55 PM
RE: trying to use batch_update() - by richb201 - 08-03-2020, 06:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB