SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Pulling objects from mysql and passing them to Php

    Hi,

    I have this

    PHP Code:
    function getOperations(){
    $query "SELECT * from tasks";
    $result mysql_query($query);
    while (
    $object mysql_fetch_object($result))
    {
       
    $array[] = $object;
    }

    return 
    $array;
    /* function */ 
    This gives me an array with objects. Now I want to link these objects to an Operation class so that I can refer to methods eg $object->display() that I would have specified in the Operations class. (well I intend to use the same names so it would be $operations->display(). )

    I can pass on the values of a single object to one specified in the class by using

    PHP Code:
    class operations {
    var 
    $jobId;
    var 
    $taskId;

    function 
    setValues(){

    ... 
    //skipped code that allows me to connect to the database

    $query "SELECT * from task_job ";
    $result mysql_query($query);
    $values mysql_fetch_array($result));

    $this->jobId $values['jobId'];
    $this->taskId $values['taskId'];

    }

    /*operations*/ 
    so using the above example I can get one object. Only. I need to get all the objects.

    Please help.

  2. #2
    SitePoint Addict fesh's Avatar
    Join Date
    Jan 2005
    Location
    Jackson, New Jersey
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do like

    $array = array();

    $array = $object->getOperations();


    to fill an array

    then loop through and display them.
    Fesh
    imagine what it's going to be like


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •