0
Angry-dev
89d

Fucking wrong parameter number.

select id,
name,
email,
logo,
IF(company_contact_ids is null, 0, contact_count) as contact_count

from (
select `companies`.`id`,
`name`,
`email`,
`phone`,
`logo`,
COUNT('company_contact.id') as contact_count,
GROUP_CONCAT(company_contact.id) as company_contact_ids
from `companies`

left join `company_contact` on `company_contact`.`company_id` = `companies`.`id`
where name like '%:name%'

group by `companies`.`id`

order by `name` asc

) as companies;

how many parameters do you see? I see 1.

https://pasteboard.co/KjDUjA3.png

Now how many parameters you see in $bindings array? I see 1

Fuck you laravel creators - it is not fucking wrong count. Why this error lies to me? Or what fucking count do you expect if I defined in the fucking query 1 parameter?

Comments
  • 0
    here is short version
    $companies = DB::select("select id from companies where name like '%:name%'", ['name' => 'a']);
    how can this be invalid parameter number?
    solved this way
    $companies = DB::select("select id from companies where name like :name", ['name' => '%a%']);

    Idiots. whats they fucking difference ? added fuckgin % signs to user data and hten it works even if they are not user fukcing input!!!! I needed to clean only user fucking input!!! wasted so fucking much time for this shit.

    And googling cannot even find such thing. Actually after fixing found somebody had same problem and there is solution
    https://stackoverflow.com/questions...
    so fucking hard to find. Why even make such problem. Make fukcing clearer fucking message because parameter number was fucking correct. Only that needed those % sings add to fucking user input.
  • 1
    Group Concat is smelly design.

    It has a fixed limit of chars..

    Your solution is pretty much anti SQL...

    A join and a sum with group should suffice.
  • 0
    @IntrusionCM I tried sum but it did not work. The group concat limit does not matter to me if it does not crash because of limit. I just need it to see if that result is null or not.
Add Comment