Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Creating An Object For Each Row From Db Result.

bind_param

  • Please log in to reply
No replies to this topic

#1 Dorgon

Dorgon

    CC Regular

  • Member
  • PipPipPip
  • 37 posts

Posted 27 May 2012 - 03:39 AM

Good morning,

I have question about database results.
At the moment I have a query that gets the "bewijskaarten" from the database that the user made.
function get_bewijskaarten_current_user($un){
    
        $bewijs_query = ("SELECT * FROM bewijskaarten WHERE username= ?");

        if($bewijsstatement = $this->connection->prepare($bewijs_query)) {
            $bewijsstatement->bind_param('s', $un);
            $bewijsstatement->execute();
            
            if($bewijsstatement->fetch()) {
                $bewijsstatement->close();
                return true;
            }
        }
    }

now, in this function:
function get_bewijskaarten_from_user($un) {
        $bewijssql = New Mysql();
        $getbewijskaarten = $bewijssql->get_bewijskaarten_current_user($un);
        
        if ($getbewijskaarten) {
            
            return $getbewijskaarten;
        }
    }

I want to make a new object of the class bewijskaart:
public function bewijskaart($bewijskaartid, $kortebeschrijving, $situatie, $taak, $aanpak, $resultaat, $reflectie) {
        $this->bewijskaartid = $bewijskaartid;
        $this->kortebeschrijving = $kortebeschrijving;
        $this->situatie = $situatie;
        $this->taak = $taak;
        $this->aanpak = $aanpak;
        $this->resultaat = $resultaat;
        $this->reflectie = $reflectie;    
    }

And on the page where user can view the list of their bewijskaarten I want to show them a part of the result of the query (just $kortebeschrijving and $bewijskaartid) in a table.
When they want to see the whole "bewijskaart" they have to select it ($situatie,$taak,$aanpak, $resultaat and $reflectie can be between 1 and 500 varchar).

Is my idea good or is there a better way?
On a other forum they said I had to look at this, but this isn't what I meant.
  • 0





Also tagged with one or more of these keywords: bind_param

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download