Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Nazlobudnya's avatar

DB insert doesn't work but raw query in MySQL CLI does

I have the following query

insert into ports (id, un_country, un_location, un_name, un_subdivision, un_status, un_function, un_remarks, coordinate, alternate_names) values ('1', 'AD', 'ALV', 'Andorra la Vella', '', 'AI', '--34-6--', '601', '0x000000000101000000F6285C8FC2F5F43F6666666666264540', '')

It easily works using MySQL CLI or something like Phpstorm db console but once I try to execute it using

DB::table('ports')->insert($values) 

for bulk insert I get the

SQLSTATE[22003]: Numeric value out of range: 1416 Cannot get geometry object from data you send to the GEOMETRY field

I'm doing bulk insert and the mentioned $values variable contains an array of arrays imported from csv like

[
'un_country' => "AD"
'un_location' => "ALV"
...
]

All the data is taken from another database with the same settings so out of range error looks a little bit off.

I understand that it might be not even a GEOMETRY problem but something else. Please help.

0 likes
4 replies
jlrdw's avatar

Put in array: Just example:

            $postdata = array(
                'dogpic' => $dogpic,
                'dogname' => $dogname,
                'sex' => $sex,
                'comments' => $comments,
                'adopted' => $adopted,
                'lastedit' => $lastedit
            );

            DB::table('dc_dogs')->insert($postdata);
Nazlobudnya's avatar

Thanks for replying. Edited the original post. I already have an array of arrays.

jlrdw's avatar
jlrdw
Best Answer
Level 75

Use getPdo ().

1 like

Please or to participate in this conversation.