当前位置:首页 > PHP教程 > php高级应用 > 列表

PHP实现的通过参数生成MYSQL语句类完整实例

发布:smiling 来源: PHP粉丝网  添加日期:2019-09-29 16:52:01 浏览: 评论:0 

本文实例讲述了PHP实现的通过参数生成MYSQL语句类。分享给大家供大家参考,具体如下:

这个类可以通过指定的表和字段参数创建SELECT ,INSERT , UPDATE 和 DELETE 语句。

这个类可以创建SQL语句的WHERE条件,像LIKE的查询语句,使用LEFT JOIN和ORDER 语句.

  1. <?php 
  2.  
  3.  /* ******************************************************************* 
  4.  
  5. Example file 
  6.  
  7. This example shows how to use the MyLibSQLGen class 
  8.  
  9. The example is based on the following MySQL table: 
  10.  
  11. CREATE TABLE customer ( 
  12.  
  13.  id int(10) unsigned NOT NULL auto_increment, 
  14.  
  15.  name varchar(60) NOT NULL default '', 
  16.  
  17.  address varchar(60) NOT NULL default '', 
  18.  
  19.  city varchar(60) NOT NULL default '', 
  20.  
  21.  PRIMARY KEY (cust_id) 
  22.  
  23. ) TYPE=MyISAM; 
  24.  
  25. ******************************************************************* */ 
  26.  
  27.  require_once ( " class_mylib_SQLGen-1.0.php " ); 
  28.  
  29.  $fields = Array ( " name " , " address " , " city " ); 
  30.  
  31.  $values = Array ( " Fadjar " , " Resultmang Raya Street " , " Jakarta " ); 
  32.  
  33.  $tables = Array ( " customer " ); 
  34.  
  35.  echo  " <b>Result Generate Insert</b><br> " ; 
  36.  
  37.  $object = new MyLibSQLGen(); 
  38.  
  39.  $object -> clear_all_assign(); // to refresh all property but it no need when first time execute  
  40.  
  41.  $object -> setFields( $fields ); 
  42.  
  43.  $object -> setValues( $values ); 
  44.  
  45.  $object -> setTables( $tables ); 
  46.  
  47.  if ( ! $object -> getInsertSQL()){ echo  $object -> Error; exit ;} 
  48.  
  49.  else { $sql = $object -> Result; echo  $sql . " <br> " ;} 
  50.  
  51.  echo  " <b>Result Generate Update</b><br> " ; 
  52.  
  53.  $fields = Array ( " name " , " address " , " city " ); 
  54.  
  55.  $values = Array ( " Fadjar " , " Resultmang Raya Street " , " Jakarta " ); 
  56.  
  57.  $tables = Array ( " customer " ); 
  58.  
  59.  $id = 1 ; 
  60.  
  61.  $conditions [ 0 ][ " condition " ] = " id='$id' " ; 
  62.  
  63.  $conditions [ 0 ][ " connection " ] = "" ; 
  64.  
  65.  $object -> clear_all_assign(); 
  66.  
  67.  $object -> setFields( $fields ); 
  68.  
  69.  $object -> setValues( $values ); 
  70.  
  71.  $object -> setTables( $tables ); 
  72.  
  73.  $object -> setConditions( $conditions ); 
  74.  
  75.  if ( ! $object -> getUpdateSQL()){ echo  $object -> Error; exit ;} 
  76.  
  77.  else { $sql = $object -> Result; echo  $sql . " <br> " ;} 
  78.  
  79.  echo  " <b>Result Generate Delete</b><br> " ; 
  80.  
  81.  $tables = Array ( " customer " ); 
  82.  
  83.  $conditions [ 0 ][ " condition " ] = " id='1' " ; 
  84.  
  85.  $conditions [ 0 ][ " connection " ] = " OR " ; 
  86.  
  87.  $conditions [ 1 ][ " condition " ] = " id='2' " ; 
  88.  
  89.  $conditions [ 1 ][ " connection " ] = " OR " ; 
  90.  
  91.  $conditions [ 2 ][ " condition " ] = " id='4' " ; 
  92.  
  93.  $conditions [ 2 ][ " connection " ] = "" ; 
  94.  
  95.  $object -> clear_all_assign(); 
  96.  
  97.  $object -> setTables( $tables ); 
  98.  
  99.  $object -> setConditions( $conditions ); 
  100.  
  101.  if ( ! $object -> getDeleteSQL()){ echo  $object -> Error; exit ;} 
  102.  
  103.  else { $sql = $object -> Result; echo  $sql . " <br> " ;} 
  104.  
  105.  echo  " <b>Result Generate List</b><br> " ; 
  106.  
  107.  $fields = Array ( " id " , " name " , " address " , " city " ); 
  108.  
  109.  $tables = Array ( " customer " ); 
  110.  
  111.  $id = 1 ; 
  112.  
  113.  $conditions [ 0 ][ " condition " ] = " id='$id' " ; 
  114.  
  115.  $conditions [ 0 ][ " connection " ] = "" ; 
  116.  
  117.  $object -> clear_all_assign(); 
  118.  
  119.  $object -> setFields( $fields ); 
  120.  
  121.  $object -> setTables( $tables ); 
  122.  
  123.  $object -> setConditions( $conditions ); 
  124.  
  125.  if ( ! $object -> getQuerySQL()){ echo  $object -> Error; exit ;} 
  126.  
  127.  else { $sql = $object -> Result; echo  $sql . " <br> " ;} 
  128.  
  129.  echo  " <b>Result Generate List with search on all fields</b><br> " ; 
  130.  
  131.  $fields = Array ( " id " , " name " , " address " , " city " ); 
  132.  
  133.  $tables = Array ( " customer " ); 
  134.  
  135.  $id = 1 ; 
  136.  
  137.  $search = " Fadjar Nurswanto " ; 
  138.  
  139.  $object -> clear_all_assign(); 
  140.  
  141.  $object -> setFields( $fields ); 
  142.  
  143.  $object -> setTables( $tables ); 
  144.  
  145.  $object -> setSearch( $search ); 
  146.  
  147.  if ( ! $object -> getQuerySQL()){ echo  $object -> Error; exit ;} 
  148.  
  149.  else { $sql = $object -> Result; echo  $sql . " <br> " ;} 
  150.  
  151.  echo  " <b>Result Generate List with search on some fields</b><br> " ; 
  152.  
  153.  $fields = Array ( " id " , " name " , " address " , " city " ); 
  154.  
  155.  $tables = Array ( " customer " ); 
  156.  
  157.  $id = 1 ; 
  158.  
  159.  $search = Array ( 
  160.  
  161.        " name " => " Fadjar Nurswanto " ,  
  162.  
  163.        " address " => " Tomang Raya " 
  164.  
  165.     ); 
  166.  
  167.  $object -> clear_all_assign(); 
  168.  
  169.  $object -> setFields( $fields ); 
  170. //phpfensi.com 
  171.  $object -> setTables( $tables ); 
  172.  
  173.  $object -> setSearch( $search ); 
  174.  
  175.  if ( ! $object -> getQuerySQL()){ echo  $object -> Error; exit ;} 
  176.  
  177.  else { $sql = $object -> Result; echo  $sql . " <br> " ;} 
  178.  
  179. ?>  

类代码:

  1. <?php 
  2.  
  3.  /*  
  4.  
  5. Created By    : Fadjar Nurswanto <fajr_n@rindudendam.net> 
  6.  
  7. DATE      : 2006-08-02 
  8.  
  9. PRODUCTNAME    : class MyLibSQLGen 
  10.  
  11. PRODUCTVERSION  : 1.0.0 
  12.  
  13. DESCRIPTION    : class yang berfungsi untuk menggenerate SQL 
  14.  
  15. DENPENCIES    : 
  16.  
  17.  */ 
  18.  
  19.  class MyLibSQLGen 
  20.  
  21. { 
  22.  
  23.    var  $Result ; 
  24.  
  25.    var  $Tables = Array (); 
  26.  
  27.    var  $Values = Array (); 
  28.  
  29.    var  $Fields = Array (); 
  30.  
  31.    var  $Conditions = Array (); 
  32.  
  33.    var  $Condition ; 
  34.  
  35.    var  $LeftJoin = Array (); 
  36.  
  37.    var  $Search ; 
  38.  
  39.    var  $Sort = " ASC " ; 
  40.  
  41.    var  $Order ; 
  42.  
  43.    var  $Error ; 
  44.  
  45.    function MyLibSQLGen(){} 
  46.  
  47.    function BuildCondition() 
  48.  
  49.   { 
  50.  
  51.      $funct = " BuildCondition " ; 
  52.  
  53.      $className = get_class ( $this ); 
  54.  
  55.      $conditions = $this -> getConditions(); 
  56.  
  57.      if ( ! $conditions ){ $this -> dbgDone( $funct ); return  true ;} 
  58.  
  59.      if ( ! is_array ( $conditions )) 
  60.  
  61.     { 
  62.  
  63.        $this -> Error = " $className::$funct Variable conditions not Array " ; 
  64.  
  65.        return ; 
  66.  
  67.     } 
  68.  
  69.      for ( $i = 0 ; $i < count ( $conditions ); $i ++ ) 
  70.  
  71.     { 
  72.  
  73.        $this -> Condition .= $conditions [ $i ][ " condition " ] . "  " . $conditions [ $i ][ " connection " ] . "  " ; 
  74.  
  75.     } 
  76.  
  77.      return  true ; 
  78.  
  79.   } 
  80.  
  81.    function BuildLeftJoin() 
  82.  
  83.   { 
  84.  
  85.      $funct = " BuildLeftJoin " ; 
  86.  
  87.      $className = get_class ( $this ); 
  88.  
  89.      if ( ! $this -> getLeftJoin()){ $this -> Error = " $className::$funct Property LeftJoin was empty " ; return ;} 
  90.  
  91.      $LeftJoinVars = $this -> getLeftJoin(); 
  92.  
  93.      $hasil = false ; 
  94.  
  95.      foreach ( $LeftJoinVars  as  $LeftJoinVar ) 
  96.  
  97.     { 
  98.  
  99.       @ $hasil .= " LEFT JOIN " . $LeftJoinVar [ " table " ]; 
  100.  
  101.        foreach ( $LeftJoinVar [ " on " ] as  $var ) 
  102.  
  103.       { 
  104.  
  105.         @ $condvar .= $var [ " condition " ] . "  " . $var [ " connection " ] . "  " ; 
  106.  
  107.       } 
  108.  
  109.        $hasil .= " ON ( " . $condvar . " ) " ; 
  110.  
  111.        unset ( $condvar ); 
  112.  
  113.     } 
  114.  
  115.      $this -> ResultLeftJoin = $hasil ; 
  116.  
  117.      return  true ; 
  118.  
  119.   } 
  120.  
  121.    function BuildOrder() 
  122.  
  123.   { 
  124.  
  125.      $funct = " BuildOrder " ; 
  126.  
  127.      $className = get_class ( $this ); 
  128.  
  129.      if ( ! $this -> getOrder()){ $this -> Error = " $className::$funct Property Order was empty " ; return ;} 
  130.  
  131.      if ( ! $this -> getFields()){ $this -> Error = " $className::$funct Property Fields was empty " ; return ;} 
  132.  
  133.      $Fields = $this -> getFields(); 
  134.  
  135.      $Orders = $this -> getOrder(); 
  136.  
  137.      if ( ereg ( " , " , $Orders )){ $Orders = explode ( " , " , $Order );} 
  138.  
  139.      if ( ! is_array ( $Orders )){ $Orders = Array ( $Orders );} 
  140.  
  141.      foreach ( $Orders  as  $Order ) 
  142.  
  143.     { 
  144.  
  145.        if ( ! is_numeric ( $Order )){ $this -> Error = " $className::$funct Property Order not Numeric " ; return ;} 
  146.  
  147.        if ( $Order  >  count ( $this -> Fields)){ $this -> Error = " $className::$funct Max value of property Sort is " . count ( $this -> Fields); return ;} 
  148.  
  149.       @ $xorder .= $Fields [ $Order ] . " , " ; 
  150.  
  151.     } 
  152.  
  153.      $this -> ResultOrder = " ORDER BY " . substr ( $xorder , 0 ,- 1 ); 
  154.  
  155.      return  true ; 
  156.  
  157.   } 
  158.  
  159.    function BuildSearch() 
  160.  
  161.   { 
  162.  
  163.      $funct = " BuildSearch " ; 
  164.  
  165.      $className = get_class ( $this ); 
  166.  
  167.      if ( ! $this -> getSearch()){ $this -> Error = " $className::$funct Property Search was empty " ; return ;} 
  168.  
  169.      if ( ! $this -> getFields()){ $this -> Error = " $className::$funct Property Fields was empty " ; return ;} 
  170.  
  171.      $Fields = $this -> getFields(); 
  172.  
  173.      $xvalue = $this -> getSearch(); 
  174.  
  175.      if ( is_array ( $xvalue )) 
  176.  
  177.     { 
  178.  
  179.        foreach ( $Fields  as  $field ) 
  180.  
  181.       { 
  182.  
  183.          if (@ $xvalue [ $field ]) 
  184.  
  185.         { 
  186.  
  187.            $Values = explode ( "  " , $xvalue [ $field ]); 
  188.  
  189.            foreach ( $Values  as  $Value ) 
  190.  
  191.           { 
  192.  
  193.             @ $hasil .= $field . " LIKE '% " . $Value . " %' OR " ; 
  194.  
  195.           } 
  196.  
  197.            if ( $hasil ) 
  198.  
  199.           { 
  200.  
  201.             @ $hasil_final .= " ( " . substr ( $hasil , 0 ,- 4 ) . " ) AND " ; 
  202.  
  203.              unset ( $hasil ); 
  204.  
  205.           } 
  206.  
  207.         } 
  208.  
  209.       } 
  210.  
  211.        $hasil = $hasil_final ; 
  212.  
  213.     } 
  214.  
  215.      else 
  216.  
  217.     { 
  218.  
  219.        foreach ( $Fields  as  $field ) 
  220.  
  221.       { 
  222.  
  223.          $Values = explode ( "  " , $xvalue ); 
  224.  
  225.          foreach ( $Values  as  $Value ) 
  226.  
  227.         { 
  228.  
  229.           @ $hasil .= $field . " LIKE '% " . $Value . " %' OR " ; 
  230.  
  231.         } 
  232.  
  233.       } 
  234.  
  235.     } 
  236.  
  237.      $this -> ResultSearch = substr ( $hasil , 0 ,- 4 ); 
  238.  
  239.      return  true ; 
  240.  
  241.   } 
  242.  
  243.    function clear_all_assign() 
  244.  
  245.   { 
  246.  
  247.      $this -> Result = null ; 
  248.  
  249.      $this -> ResultSearch = null ; 
  250.  
  251.      $this -> ResultLeftJoin = null ; 
  252.  
  253.      $this -> Result = null ; 
  254.  
  255.      $this -> Tables = Array (); 
  256.  
  257.      $this -> Values = Array (); 
  258.  
  259.      $this -> Fields = Array (); 
  260.  
  261.      $this -> Conditions = Array (); 
  262.  
  263.      $this -> Condition = null ; 
  264.  
  265.      $this -> LeftJoin = Array (); 
  266.  
  267.      $this -> Sort = " ASC " ; 
  268.  
  269.      $this -> Order = null ; 
  270.  
  271.      $this -> Search = null ; 
  272.  
  273.      $this -> fieldSQL = null ; 
  274.  
  275.      $this -> valueSQL = null ; 
  276.  
  277.      $this -> partSQL = null ; 
  278.  
  279.      $this -> Error = null ; 
  280.  
  281.      return  true ; 
  282.  
  283.   } 
  284.  
  285.    function CombineFieldValue( $manual = false ) 
  286.  
  287.   { 
  288.  
  289.      $funct = " CombineFieldsPostVar " ; 
  290.  
  291.      $className = get_class ( $this ); 
  292.  
  293.      $fields = $this -> getFields(); 
  294.  
  295.      $values = $this -> getValues(); 
  296.  
  297.      if ( ! is_array ( $fields )) 
  298.  
  299.     { 
  300.  
  301.        $this -> Error = " $className::$funct Variable fields not Array " ; 
  302.  
  303.        return ; 
  304.  
  305.     } 
  306.  
  307.      if ( ! is_array ( $values )) 
  308.  
  309.     { 
  310.  
  311.        $this -> Error = " $className::$funct Variable values not Array " ; 
  312.  
  313.        return ; 
  314.  
  315.     } 
  316.  
  317.      if ( count ( $fields ) != count ( $values )) 
  318.  
  319.     { 
  320.  
  321.        $this -> Error = " $className::$funct Count of fields and values not match " ; 
  322.  
  323.        return ; 
  324.  
  325.     } 
  326.  
  327.      for ( $i = 0 ; $i < count ( $fields ); $i ++ ) 
  328.  
  329.     { 
  330.  
  331.       @ $this -> fieldSQL .= $fields [ $i ] . " , " ; 
  332.  
  333.        if ( $fields [ $i ] ==  " pwd "  ||  $fields [ $i ] ==  " password "  ||  $fields [ $i ] ==  " pwd " ) 
  334.  
  335.       { 
  336.  
  337.         @ $this -> valueSQL .= " password(' " . $values [ $i ] . " '), " ; 
  338.  
  339.         @ $this -> partSQL .= $fields [ $i ] . " =password(' " . $values [ $i ] . " '), " ; 
  340.  
  341.       } 
  342.  
  343.        else 
  344.  
  345.       { 
  346.  
  347.          if ( is_numeric ( $values [ $i ])) 
  348.  
  349.         { 
  350.  
  351.           @ $this -> valueSQL .= $values [ $i ] . " , " ; 
  352.  
  353.           @ $this -> partSQL .= $fields [ $i ] . " = " . $values [ $i ] . " , " ; 
  354.  
  355.         } 
  356.  
  357.          else 
  358.  
  359.         { 
  360.  
  361.           @ $this -> valueSQL .= " ' " . $values [ $i ] . " ', " ; 
  362.  
  363.           @ $this -> partSQL .= $fields [ $i ] . " =' " . $values [ $i ] . " ', " ; 
  364.  
  365.         } 
  366.  
  367.       } 
  368.  
  369.     } 
  370.  
  371.      $this -> fieldSQL = substr ( $this -> fieldSQL , 0 ,- 1 ); 
  372.  
  373.      $this -> valueSQL = substr ( $this -> valueSQL , 0 ,- 1 ); 
  374.  
  375.      $this -> partSQL = substr ( $this -> partSQL , 0 ,- 1 ); 
  376.  
  377.      return  true ; 
  378.  
  379.   } 
  380.  
  381.    function getDeleteSQL() 
  382.  
  383.   { 
  384.  
  385.      $funct = " getDeleteSQL " ; 
  386.  
  387.      $className = get_class ( $this ); 
  388.  
  389.      $Tables = $this -> getTables(); 
  390.  
  391.      if ( ! $Tables  ||  ! count ( $Tables )) 
  392.  
  393.     { 
  394.  
  395.        $this -> dbgFailed( $funct ); 
  396.  
  397.        $this -> Error = " $className::$funct Table was empty " ; 
  398.  
  399.        return ; 
  400.  
  401.     } 
  402.  
  403.      for ( $i = 0 ; $i < count ( $Tables ); $i ++ ) 
  404.  
  405.     { 
  406.  
  407.       @ $Table .= $Tables [ $i ] . " , " ; 
  408.  
  409.     } 
  410.  
  411.      $Table = substr ( $Table , 0 ,- 1 ); 
  412.  
  413.      $sql = " DELETE FROM " . $Table ; 
  414.  
  415.      if ( $this -> getConditions()) 
  416.  
  417.     { 
  418.  
  419.        if ( ! $this -> BuildCondition()){ $this -> dbgFailed( $funct ); return ;} 
  420.  
  421.        $sql .= " WHERE " . $this -> getCondition(); 
  422.  
  423.     } 
  424.  
  425.      $this -> Result = $sql ; 
  426.  
  427.      return  true ; 
  428.  
  429.   } 
  430.  
  431.    function getInsertSQL() 
  432.  
  433.   { 
  434.  
  435.      $funct = " getInsertSQL " ; 
  436.  
  437.      $className = get_class ( $this ); 
  438.  
  439.      if ( ! $this -> getValues()){ $this -> Error = " $className::$funct Property Values was empty " ; return ;} 
  440.  
  441.      if ( ! $this -> getFields()){ $this -> Error = " $className::$funct Property Fields was empty " ; return ;} 
  442.  
  443.      if ( ! $this -> getTables()){ $this -> Error = " $className::$funct Property Tables was empty " ; return ;} 
  444.  
  445.      if ( ! $this -> CombineFieldValue()){ $this -> dbgFailed( $funct ); return ;} 
  446.  
  447.      $Tables = $this -> getTables(); 
  448.  
  449.      $sql = " INSERT INTO " . $Tables [ 0 ] . " ( " . $this -> fieldSQL . " ) VALUES ( " . $this -> valueSQL . " ) " ; 
  450.  
  451.      $this -> Result = $sql ; 
  452.  
  453.      return  true ; 
  454.  
  455.   } 
  456.  
  457.    function getUpdateSQL() 
  458.  
  459.   { 
  460.  
  461.      $funct = " getUpdateSQL " ; 
  462.  
  463.      $className = get_class ( $this ); 
  464.  
  465.      if ( ! $this -> getValues()){ $this -> Error = " $className::$funct Property Values was empty " ; return ;} 
  466.  
  467.      if ( ! $this -> getFields()){ $this -> Error = " $className::$funct Property Fields was empty " ; return ;} 
  468.  
  469.      if ( ! $this -> getTables()){ $this -> Error = " $className::$funct Property Tables was empty " ; return ;} 
  470.  
  471.      if ( ! $this -> CombineFieldValue()){ $this -> dbgFailed( $funct ); return ;} 
  472.  
  473.      if ( ! $this -> BuildCondition()){ $this -> dbgFailed( $funct ); return ;} 
  474.  
  475.      $Tables = $this -> getTables(); 
  476.  
  477.      $sql = " UPDATE " . $Tables [ 0 ] . " SET " . $this -> partSQL . " WHERE " . $this -> getCondition(); 
  478.  
  479.      $this -> Result = $sql ; 
  480.  
  481.      return  true ; 
  482.  
  483.   } 
  484.  
  485.    function getQuerySQL() 
  486.  
  487.   { 
  488.  
  489.      $funct = " getQuerySQL " ; 
  490.  
  491.      $className = get_class ( $this ); 
  492.  
  493.      if ( ! $this -> getFields()){ $this -> Error = " $className::$funct Property Fields was empty " ; return ;} 
  494.  
  495.      if ( ! $this -> getTables()){ $this -> Error = " $className::$funct Property Tables was empty " ; return ;} 
  496.  
  497.      $Fields = $this -> getFields(); 
  498.  
  499.      $Tables = $this -> getTables(); 
  500.  
  501.      foreach ( $Fields  as  $Field ){@ $sql_raw .= $Field . " , " ;} 
  502.  
  503.      foreach ( $Tables  as  $Table ){@ $sql_table .= $Table . " , " ;} 
  504.  
  505.      $this -> Result = " SELECT " . substr ( $sql_raw , 0 ,- 1 ) . " FROM " . substr ( $sql_table , 0 ,- 1 ); 
  506.  
  507.      if ( $this -> getLeftJoin()) 
  508.  
  509.     { 
  510.  
  511.        if ( ! $this -> BuildLeftJoins()){ $this -> dbgFailed( $funct ); return ;} 
  512.  
  513.        $this -> Result .= "  " . $this -> ResultLeftJoin; 
  514.  
  515.     } 
  516.  
  517.      if ( $this -> getConditions()) 
  518.  
  519.     { 
  520.  
  521.        if ( ! $this -> BuildCondition()){ $this -> dbgFailed( $funct ); return ;} 
  522.  
  523.        $this -> Result .= " WHERE ( " . $this -> Condition . " ) " ; 
  524.  
  525.     } 
  526.  
  527.      if ( $this -> getSearch()) 
  528.  
  529.     { 
  530.  
  531.        if ( ! $this -> BuildSearch()){ $this -> dbgFailed( $funct ); return ;} 
  532.  
  533.        if ( $this -> ResultSearch) 
  534.  
  535.       { 
  536.  
  537.          if ( eregi ( " WHERE " , $this -> Result)){ $this -> Result .= " AND " . $this -> ResultSearch;} 
  538.  
  539.          else { $this -> Result .= " WHERE " . $this -> ResultSearch;} 
  540.  
  541.       } 
  542.  
  543.     } 
  544.  
  545.      if ( $this -> getOrder()) 
  546.  
  547.     { 
  548.  
  549.        if ( ! $this -> BuildOrder()){ $this -> dbgFailed( $funct ); return ;} 
  550.  
  551.        $this -> Result .= "  " . $this -> ResultOrder; 
  552.  
  553.     } 
  554.  
  555.      if ( $this -> getSort()) 
  556.  
  557.     { 
  558.  
  559.        if (@ $this -> ResultOrder) 
  560.  
  561.       { 
  562.  
  563.          $this -> Result .= "  " . $this -> getSort(); 
  564.  
  565.       } 
  566.  
  567.     } 
  568.  
  569.      return  true ; 
  570.  
  571.   } 
  572.  
  573.    function getCondition(){ return @ $this -> Condition;} 
  574.  
  575.    function getConditions(){ if ( count (@ $this -> Conditions) &&  is_array (@ $this -> Conditions)){ return @ $this -> Conditions;}} 
  576.  
  577.    function getFields(){ if ( count (@ $this -> Fields) &&  is_array (@ $this -> Fields)){ return @ $this -> Fields;}} 
  578.  
  579.    function getLeftJoin(){ if ( count (@ $this -> LeftJoin) &&  is_array (@ $this -> LeftJoin)){ return @ $this -> LeftJoin;}} 
  580.  
  581.    function getOrder(){ return @ $this -> Order;} 
  582.  
  583.    function getSearch(){ return @ $this -> Search;} 
  584.  
  585.    function getSort(){ return @ $this -> Sort ;} 
  586.  
  587.    function getTables(){ if ( count (@ $this -> Tables) &&  is_array (@ $this -> Tables)){ return @ $this -> Tables;}} 
  588.  
  589.    function getValues(){ if ( count (@ $this -> Values) &&  is_array (@ $this -> Values)){ return @ $this -> Values;}} 
  590.  
  591.    function setCondition( $input ){ $this -> Condition = $input ;} 
  592.  
  593.    function setConditions( $input ) 
  594.  
  595.   { 
  596.  
  597.      if ( is_array ( $input )){ $this -> Conditions = $input ;} 
  598.  
  599.      else { $this -> Error = get_class ( $this ) . " ::setConditions Parameter input not array " ; return ;} 
  600.  
  601.   } 
  602.  
  603.    function setFields( $input ) 
  604.  
  605.   { 
  606.  
  607.      if ( is_array ( $input )){ $this -> Fields = $input ;} 
  608.  
  609.      else { $this -> Error = get_class ( $this ) . " ::setFields Parameter input not array " ; return ;} 
  610.  
  611.   } 
  612.  
  613.    function setLeftJoin( $input ) 
  614.  
  615.   { 
  616.  
  617.      if ( is_array ( $input )){ $this -> LeftJoin = $input ;} 
  618.  
  619.      else { $this -> Error = get_class ( $this ) . " ::setFields Parameter input not array " ; return ;} 
  620.  
  621.   } 
  622.  
  623.    function setOrder( $input ){ $this -> Order = $input ;} 
  624.  
  625.    function setSearch( $input ){ $this -> Search = $input ;} 
  626.  
  627.    function setSort( $input ){ $this -> Sort = $input ;} 
  628.  
  629.    function setTables( $input ) 
  630.  
  631.   { 
  632.  
  633.      if ( is_array ( $input )){ $this -> Tables = $input ;} 
  634.  
  635.      else { $this -> Error = get_class ( $this ) . " ::setTables Parameter input not array " ; return ;} 
  636.  
  637.   } 
  638.  
  639.    function setValues( $input ) 
  640.  
  641.   { 
  642.  
  643.      if ( is_array ( $input )){ $this -> Values = $input ;} 
  644.  
  645.      else { $this -> Error = get_class ( $this ) . " ::setValues Parameter input not array " ; return ;} 
  646.  
  647.   } 
  648.  
  649. } 
  650.  
  651. ?>  
  652.  
  653. </fajr_n@rindudendam.net> 

Tags: PHP生成MYSQL

分享到:

相关文章