update mysql library
This commit is contained in:
@@ -334,9 +334,10 @@ class MySqlManager extends PhpObject
|
||||
|
||||
public function updateRows($sTableName, $asConstraints, $asData, $iLimit=0)
|
||||
{
|
||||
$sTableIdCol = self::getId($sTableName);
|
||||
if(!is_array($asConstraints))
|
||||
{
|
||||
$asConstraints = array($this->getId($sTableName)=>$asConstraints);
|
||||
$asConstraints = array($sTableIdCol=>$asConstraints);
|
||||
}
|
||||
|
||||
$this->cleanSql($sTableName);
|
||||
@@ -356,7 +357,12 @@ class MySqlManager extends PhpObject
|
||||
$iResult = false;
|
||||
if($this->setQuery($sQuery))
|
||||
{
|
||||
$iResult = ($iLimit==1)?$this->selectValue($sTableName, $this->getId($sTableName), $asConstraints):true;
|
||||
$this->setTrace(true);
|
||||
if($iLimit==1)
|
||||
{
|
||||
$iResult = array_key_exists($sTableIdCol, $asConstraints)?$asConstraints[$sTableIdCol]:$this->selectValue($sTableName, $sTableIdCol, $asConstraints);
|
||||
}
|
||||
else $iResult = true;
|
||||
}
|
||||
return $iResult;
|
||||
}
|
||||
@@ -385,7 +391,7 @@ class MySqlManager extends PhpObject
|
||||
{
|
||||
unset($asData[$sTableIdName]);
|
||||
}
|
||||
$iTableId = $this->updateRow($sTableName, $iTableId, $asData);
|
||||
$this->updateRow($sTableName, $iTableId, $asData);
|
||||
}
|
||||
return $iTableId;
|
||||
}
|
||||
@@ -438,13 +444,22 @@ class MySqlManager extends PhpObject
|
||||
$sIdColumnName);
|
||||
}
|
||||
|
||||
public function selectRows($asInfo, $bStringOnly=true, $sGroupBy='')
|
||||
public function selectRows($asInfo, $sGroupBy='', $bStringOnly=true)
|
||||
{
|
||||
$asAttributes = array('select'=>"SELECT", 'from'=>"FROM", 'join'=>"LEFT JOIN", 'joinOn'=>"LEFT JOIN", 'constraint'=>"WHERE", 'groupBy'=>"GROUP BY", 'orderBy'=>"ORDER BY", 'limit'=>'LIMIT');
|
||||
$asRowSeparators = array('select'=>", ", 'from'=>"", 'join'=>" LEFT JOIN ", 'joinOn'=>" LEFT JOIN ", 'constraint'=>" AND ", 'groupBy'=>", ", 'orderBy'=>", ", 'limit'=>"");
|
||||
$asOperators = array('constraint'=>" = ", 'orderBy'=>" ", 'join'=>" USING(", 'joinOn'=>" ON ");
|
||||
$asEndOfStatement = array('constraint'=>"", 'orderBy'=>"", 'join'=>")", 'joinOn'=>"");
|
||||
|
||||
//Get table by key
|
||||
if($sGroupBy===true)
|
||||
{
|
||||
$sGroupBy = self::getId($asInfo['from']);
|
||||
|
||||
//Add id to selection
|
||||
if(isset($asInfo['select']) && $asInfo['select'][0]!="*") $asInfo['select'][] = $sGroupBy;
|
||||
}
|
||||
|
||||
$sQuery = "";
|
||||
foreach($asAttributes as $sStatement => $sKeyWord)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user