ZengCode.Com (The Thai Php Framework)  


Home   Download   Manual   About us    

Facebook   


MAIN MENU
News
Php Tips
Android Programming
Design Pattern By PHP
C# using Linq น่าใช้จริงๆ
C# Tips & Technique
C# Design Pattern
Linux Quick Tips
Java & JavaScript Tips
Database & SQL
ZengCode Framework Guide
Zeng Code Code
Programming
IPhone (Tips and Trick)

Download เอกสารที่น่าสนใจ

     GenerateInsertQuery & GenerateUpdateQuery  (2009-09-28)


public function GenerateInsertQuery($data)
{   
   $query = "Insert into ".$data['table'];
   $tmp = NULL;
   $tmp2= NULL;
   foreach($data['fields']  as $fieldName => $fieldType)
   {
         if ($tmp == NULL) $tmp .= " (".$fieldName;
         else              $tmp .= ",".$fieldName;

         if ($tmp2 == NULL) $tmp2.=  "(";
         else               $tmp2 .= ",";

         $fieldType=strtoupper($fieldType);
         switch ($fieldType)
         {
          case 'GET' : $tmp2 .= "'".$_GET[$fieldName]."'";
                        break;
          case 'POST' : $tmp2 .= "'".$_POST[$fieldName]."'";
                        break;
          case 'VAR'  : $tmp2 .= "'".$GLOBALS[$fieldName]."'";
                        break;
         }//swithch
   }//foreach
   $tmp .=") Values ";
   $tmp2.=")";
   $query .= $tmp.$tmp2;
   return $query;
}

public function GenerateUpdateQuery($data,$condition)
{   
   $query = NULL;
   foreach($data['fields']  as $fieldName => $fieldType)
   {
         if ($query == NULL) $query = "Update ".$data['table']." SET ";
         else               $query .= ",";
         $fieldType=strtoupper($fieldType);
         switch ($fieldType)
         {
          case 'GET' :  $query .= $fieldName."='".$_GET[$fieldName]."'";
                        break;
          case 'POST' : $query .= $fieldName."='".$_POST[$fieldName]."'";
                        break;
          case 'VAR'  : $query .= $fieldName."='".$GLOBALS[$fieldName]."'";
                        break;
         }//swithch
   }//foreach
   $query .= " Where ".$condition;
   return $query;
}


Comment
Name
Comment
Security CodeCAPTCHA Image

easy tracking
avis car rental discount code

This page took 0.038431 seconds to load.