Jump to content

Help with class array to sql


HelpMe100

Recommended Posts

Please help me with this problem.

 

I've got a class with an array in it, and some data in the array.

 

 

I instantiate the class as myArray class, and pass it to a function, the function uses the array in the class as input for a mysql database. The problem is the sql wont input the data. I can insert into the database via sql local variables and local arrays and class variables but not class arrays? if i save the class array to a local variable and insert that into the sql then that works, but it wont go straight in? I imagine this has to do with passing the array by refrence rather than by value as i get "array[]" as the value in the database but i can't be sure.

 

pseudo code:

 

class arrayclass()

  {

  var options;

  options[0]="foo";

  }

 

Function insertData(myArray)

  {

  //THIS WORKS

  echo myArray->options[0]; 

 

  //BUT THIS DOESN'T

  mysql_query("UPDATE OPTIONS SET bar='myArray->options[0]' WHERE EVER ");

  }

 

myArray = new arrayClass();

insertdata(myArray);

 

Please help.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.