0

I am trying to delete some elements of an array resulting from a fetch from a function in a class:

public function isChecked($db, $table, $id, $row_id)
{
    $answer = $db->query("SELECT * FROM $table WHERE $row_id =  $id")->fetch(); 

    var_dump($answer);
}

I get the following result:

object(stdClass)#2 (5) { ["act_prim"]=> string(2) "12" ["act_id"]=>string(1) "1" ["a"]=> NULL ["b"]=> string(1) "1" ["c"]=> string(1) "1" } 

I would like to remove the 2 first elements ("act_prim" and "act_id") from the array. But so far I dident succeed with any method.

Thanks for your help.

michltm
  • 1,399
  • 2
  • 13
  • 33
  • not sure if it'll work, but try unset($answer->act_prim). In any case, you should not do it this way. If you don't need those columns - don't select them! Use "SELECT column1,column2,..columnX FROM table" instead – Marius Jul 21 '15 at 18:55
  • Right, sorry that I dident see it, this question has indeed already been answered and the solution works great. Just to answer Marius, I did it this way because I have a lot of columns to select (around 50) and only 2 to remove, and I dident find a way to do that query without having to rewrite all the column names. – michltm Jul 22 '15 at 07:36

0 Answers0