动态网页技术PHP通过参数来生成MYSQL语句类(2)
Property Values was empty " ; return ;}
if ( ! $this -> getFields()){ $this -> Error = " $className::$funct
Property Fields was empty " ; return ;}
if ( ! $this -> getTables()){ $this -> Error = " $className::$funct
Property Tables was empty " ; return ;}
if ( ! $this -> CombineFieldValue()){ $this -> dbgFailed( $funct ); return ;}
if ( ! $this -> BuildCondition()){ $this -> dbgFailed( $funct ); return ;}
$Tables = $this -> getTables();
$sql = " UPDATE " . $Tables [ 0 ] . " SET " . $this -> partSQL . " WHERE " . $this -> getCondition();
$this -> Result = $sql ;
return true ;
}
function getQuerySQL()
{
$funct = " getQuerySQL " ;
$className = get_class ( $this );
if ( ! $this -> getFields()){ $this -> Error = " $className::$funct
Property Fields was empty " ; return ;}
if ( ! $this -> getTables()){ $this -> Error = " $className::$funct
Property Tables was empty " ; return ;}
$Fields = $this -> getFields();
$Tables = $this -> getTables();
foreach ( $Fields as $Field ){@ $sql_raw .= $Field . " , " ;}
foreach ( $Tables as $Table ){@ $sql_table .= $Table . " , " ;}
$this -> Result = " SELECT " . substr ( $sql_raw , 0 ,- 1 ) . " FROM " . substr ( $sql_table , 0 ,- 1 );
if ( $this -> getLeftJoin())
{
if ( ! $this -> BuildLeftJoins()){ $this -> dbgFailed( $funct ); return ;}
$this -> Result .= " " . $this -> ResultLeftJoin;
}
if ( $this -> getConditions())
{
if ( ! $this -> BuildCondition()){ $this -> dbgFailed( $funct ); return ;}
$this -> Result .= " WHERE ( " . $this -> Condition . " ) " ;
}
if ( $this -> getSearch())
{
if ( ! $this -> BuildSearch()){ $this -> dbgFailed( $funct ); return ;}
if ( $this -> ResultSearch)
{
if ( eregi ( " WHERE " , $this -> Result)){ $this -> Result .= " AND " . $this -> ResultSearch;}
else { $this -> Result .= " WHERE " . $this -> ResultSearch;}
}
}
if ( $this -> getOrder())
{
if ( ! $this -> BuildOrder()){ $this -> dbgFailed( $funct ); return ;}
$this -> Result .= " " . $this -> ResultOrder;
}
if ( $this -> getSort())
{
if (@ $this -> ResultOrder)
{
$this -> Result .= " " . $this -> getSort();
}
}
return true ;
}
function getCondition(){ return @ $this -> Condition;}
function getConditions(){ if ( count (@ $this -> Conditions) && is_array (@ $this -> Conditions)){ return @ $this -> Conditions;}}
function getFields(){ if ( count (@ $this -> Fields) && is_array (@ $this -> Fields)){ return @ $this -> Fields;}}
function getLeftJoin(){ if ( count (@ $this -> LeftJoin) && is_array (@ $this -> LeftJoin)){ return @ $this -> LeftJoin;}}
function getOrder(){ return @ $this -> Order;}
function getSearch(){ return @ $this -> Search;}
function getSort(){ return @ $this -> Sort ;}
function getTables(){ if ( count (@ $this -> Tables) && is_array (@ $this -> Tables)){ return @ $this -> Tables;}}
function getValues(){ if ( count (@ $this -> Values) && is_array (@ $this -> Values)){ return @ $this -> Values;}}
function setCondition( $input ){ $this -> Condition = $input ;}
function setConditions( $input )
{
if ( is_array ( $input )){ $this -> Conditions = $input ;}
else { $this -> Error = get_class ( $this ) . " ::setConditions
Parameter input not array " ; return ;}
}
function setFields( $input )
{
if ( is_array ( $input )){ $this -> Fields = $input ;}
else { $this -> Error = get_class ( $this ) . " ::setFields
Parameter input not array " ; return ;}
}
function setLeftJoin( $input )
{
if ( is_array ( $input )){ $this -> LeftJoin = $input ;}
else { $this -> Error = get_class ( $this ) . " ::setFields
Parameter input not array " ; return ;}
}
function setOrder( $input ){ $this -> Order = $input ;}
function setSearch( $input ){ $this -> Search = $input ;}
function setSort( $input ){ $this -> Sort = $input ;}
function setTables( $input )
{
if ( is_array ( $input )){ $this -> Tables = $input ;}
else { $this -> Error = get_class ( $this ) . " ::setTables
Parameter input not array " ; return ;}
}
function setValues( $input )
{
if ( is_array ( $input )){ $this -> Values = $input ;}
else { $this -> Error = get_class ( $this ) . " ::setValues
Parameter input not array " ; return ;}
}
}
?>
顶(0)
踩(0)
上一篇:PHP+MySQL扎实基本功
下一篇:PHP常用正则表达式收集
- 最新评论