1 Reply Latest reply on Aug 2, 2011 5:09 AM by whitefinger

    Need advise on cleaning up my PHP! please for flash builder

    whitefinger Level 1

      Ok so i only found flash builder about 3 weeks ago as im trying to update an old site that i once created and the PHP code that flash builder has generated is a little confusing compaired to what im use to. But the problem i have is in my old code i had

       

      fname =    ucfirst(fname);
      fname = substr(fname,0,1);
      lname = ucfirst(lname);
      town = ucfirst(town);

       

      to format the text to the way i want it but trying to put this in the code that flash builder has created just causes errors so im assuming i dont know what im doing so can someone please advise?

       

      class ClientsService {

          var
      $username = "";
          var
      $password = "";
          var
      $server = "localhost";
          var
      $port = "3306";
          var
      $databasename = "totalclients";
          var
      $tablename = "clients";

          var
      $connection;

         
      public function __construct() {
               
      $this->connection = mysqli_connect(
                                       
      $this->server,  
                                       
      $this->username,  
                                       
      $this->password
                                       
      $this->databasename,
                                       
      $this->port
                                   
      );

             
      $this->throwExceptionOnError($this->connection);
          }

         
      public function getAllClients() {

             
      $stmt = mysqli_prepare($this->connection, "SELECT  timestamp, id, fname, lname, sex, country, town, dateofbirth,  monthofbirth, yearofbirth from $this->tablename ORDER BY id DESC  LIMIT 9");        
             
      $this->throwExceptionOnError();
              
             
      mysqli_stmt_execute($stmt);
             
      $this->throwExceptionOnError();
              
             
      $rows = array();
              
             
      mysqli_stmt_bind_result($stmt, $row->timestamp, $row->ID, $row->fname, $row->lname$row->sex, $row->country, $row->town, $row->dateofbirth, $row->monthofbirth, $row->yearofbirth);
              
              while (
      mysqli_stmt_fetch($stmt)) {
               
      $row->timestamp = new DateTime($row->timestamp);
               
      $rows[] = $row;
               
      $row = new stdClass();
               
      mysqli_stmt_bind_result($stmt, $row->timestamp, $row->ID, $row->fname, $row->lname$row->sex, $row->country, $row->town, $row->dateofbirth, $row->monthofbirth, $row->yearofbirth);
              }
              
             
      mysqli_stmt_free_result($stmt);
             
      mysqli_close($this->connection);
          
              return
      $rows;
          }
      Any help anyone wants to give me many thanks