Welcome Guest, Not a member yet? Register   Sign In
UUID bug with Entity
#1

Hi, there,

I'm making a seed with this example below:

Code:
$formatters = [
            'raison_social' => 'sentence',
            'nom' => 'sentence',
            'prenom' => 'sentence',
            'email'  => 'email',
        ];

        $fabricator = new Fabricator(CustomerModel::class, $formatters);

        for ($i = 0; $i < 5; $i++) {
            $data[] = $fabricator->make();
            $data[$i]->uuid = newUUID();
            $data[$i]->code_client = 'xfgsdfgfdsgsdfg';
            $data[$i]->id_country = 8;
            $data[$i]->type = 1;
            $data[$i]->reference = "fsgdsfgfdg";
            $data[$i]->corp_rateCategory = 1;
            $data[$i]->active = 1;
            $data[$i]->order = $i + 1;
        }

        print_r($data);

        $this->db->table('customers')->insertBatch($data);


But if I leave in my Model : 
PHP Code:
protected $returnType      Customer::class; 

This does not work, i.e. the database is populated but without the right information.

If I replace it with
PHP Code:
$returnType      "Object"


it works perfectly.
In my entity I have nothing.
Do you have an idea?

Thanks
Reply
#2

Did you try it with passing it the namespace?

PHP Code:
protected $returnType    = \App\Entities\User::class; 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

What happened when using Entity?
Reply
#4

(06-01-2023, 04:10 AM)kenjis Wrote: What happened when using Entity?
This code works : 
Code:
      $faker = Factory::create('id_ID');

        $data = [];
        for ($i = 0; $i < 5; $i++) {

            $data[] = [
                'uuid'    => newUUID(),
                'code_client'    => $faker->sha1,
                'id_country'        => 8,
                'raison_social' => $faker->userName,
                'nom' => $faker->lastName,
                'prenom' => $faker->firstName,
                'email' => $faker->email,
                'corp_rateCategory'    => 1,
                'active'=> 1,
                'order' => $i + 1,
                'created_at'=> $faker->dateTimeBetween('-2 month', '-1 days')->format('Y-m-d H:i:s'),

            ];

        }

on the other hand, the other code doesn't work and it doesn't return any errors. it inserts all 5 rows, but some columns are empty, like "UUID".

I don't understand
Reply
#5

(This post was last modified: 06-01-2023, 04:35 PM by kenjis.)

Does newUUID() return correct UUID?
Dump the $data value to check.
And check the executed SQL statements.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB