Usage of FIND_IN_SET in query [closed] - php

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
$query=$this->db
->select(a.date,group_concat(s.name)
->from("tbl_attendance a,tbl_students s")
->WHERE ("FIND_IN_SET(s.student_id, a.attendance)")->group_by("a.date")
->get();
I wanted to know whether I have used the FIND_IN_SET and group_by functions correctly. Thanks in advance

FIND_IN_SET() returns the position of a string if it is present (as a
substring) within a list of strings
so you should search if a value is != 0
eg:
->where("FIND_IN_SET(s.student_id, a.attendance) !=", 0)
->group_by("a.date")

Related

I would like to exclude some rows by Eloquent [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 months ago.
Improve this question
I have a user table that contains a colum "role"
i would like to exclude the ones that contains a certain role by Eloquent
Does any one knows a solution for this ?
To answer your original comment
User::query()->whereNotIn('role', 'blabla')->get();
To answer the second edit of the comment:
User::query()->whereNotIn('role', [
'Admin', 'responsable', 'magasinier', 'demandeur'
])->get();
To answer the third edit of the comment:
User::query()->whereNotIn('role', 'demandeur')->get();

PHP when md5 returns null value [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have a question.
So I was doing ctf and there was this if statement. I have no idea how to get past it.
if(isset($_POST['var']) && md5($_POST['var']) == NULL)
All I'm asking for is a little hint, thanks.
OK, here's a hint.
PHP's md5() function expects its argument to be a string.
Can you think of some way of forcing this statement to deal with a different data type?

PHP Illegal array key type warning (PHPStorm) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Here is my example code
It actually works on server but I wonder why do I get this warning?
Thanks
You can't use float number as array index.
To change floats to integer use function like intval

How to remove a key of an array? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I need to remove [picture_names] from my array. Help me to remove this?
Use unset function:
unset($array['picture_names']);
You can do it with unset() function. Documentation here.
$result = unset($yourArray['picture_names']);
var_dump($result);

How to implement a loop in php [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Hi I'm totally new here and with and would glad if someone could help as I'm stuck with how I can create a loop with some php code.
$TotalUniques = $this->TotalUniquesHits($Counts[$xx]['ID']);
The value I'm after is [$xx] which represents a position in the array. How to change it so that I get $TotalUniques looping through all the values of $xx?
You can try with foreach loop:
foreach($Counts as $xx){
$TotalUniques[] = $this->TotalUniquesHits($xx['ID']);
}
You may also consider checking if each $xx has ID key with isset or array_key_exists.

Categories