SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    911
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Arrow Is this class of mine okay?

    I just created a class with multidimensional array in it, please look below,

    Code:
    <?php
    //scraping class
    
    class casting
    {
    	public $jobs = array("casting_id" => array(
    		"job_id" => 0, 
    		"listed_on" => '', 
    		"expiration" => '', 
    		"location" => '', 
    		"gender" => '', 
    		"age" => '', 
    		"categories" => '', 		
    		"union" => '', 
    		"rate" => '', 
    		"email" => '', 
    		"description" => ''));
    	
        function __construct() {
    	
        }
    
        function __destruct() {
    
        }
    	
    	function setJobs($casting_id, $job_id, $listed_on, $expiration, $location, $gender, $age, $categories, $union, $rate, $email, $description) {
    		$this->jobs[]['job_id'] = $casting_id;
    		$this->jobs[]['listed_on'] = $job_id;
    		$this->jobs[]['listed_on'] = $listed_on;
    		$this->jobs[]['expiration'] = $expiration;
    		$this->jobs[]['location'] = $expiration;
    		$this->jobs[]['']['gender'] = $gender;
    		$this->jobs[]['age'] = $age;
    		$this->jobs[]['categories'] = $categories;
    		$this->jobs[]['union'] = $union;
    		$this->jobs[]['rate'] = $rate;
    		$this->jobs[]['email'] = $email;
    		$this->jobs[]['description'] = $description;
    	}
    	
    	function setJobs($casting_id, $job_id, $listed_on, $expiration, $location, $gender, $age, $categories, $union, $rate, $email, $description) {	
    		return $this->jobs[]['job_id'];
    		return $this->jobs[]['listed_on'];
    		return $this->jobs[]['listed_on'];
    		return $this->jobs[]['expiration'];
    		return $this->jobs[]['location'];
    		return $this->jobs[]['']['gender'];
    		return $this->jobs[]['age'] = $age;
    		return $this->jobs[]['categories'];
    		return $this->jobs[]['union'];
    		return $this->jobs[]['rate'];
    		return $this->jobs[]['email'];
    		return $this->jobs[]['description'];	
    	}
    	
    }
    
    $newcasting = new casting();
    ?>
    Can you check my class please, specially the accessing, assignment and returning the array.
    Please note the array is two dimensional, i used the array for temporary replacement for mysql.

    Can you check those please, thanks in advance.

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First of all, the setJobs() function is declared twice. I'm guessing the second one is supposed to be called getJobs(). Furthermore, the second function won't work as expected as it will stop executing after the first return command.

    Edit: also, the second function is a bit redundant anyway seeing as the $jobs array is set to public.

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,042
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Those array keys should probably be factored out into separate properties.

    The getter function is only going to return the value for job_id.


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
  •