add selectColumn function
This commit is contained in:
41
inc/db.php
41
inc/db.php
@@ -3,7 +3,7 @@
|
||||
/**
|
||||
* MySql query manager and generator
|
||||
* @author franzz
|
||||
* @version 2.0
|
||||
* @version 2.1
|
||||
*/
|
||||
class Db extends PhpObject
|
||||
{
|
||||
@@ -98,7 +98,7 @@ class Db extends PhpObject
|
||||
public function setTrace($bTrace=true)
|
||||
{
|
||||
$this->bTrace = $bTrace;
|
||||
if($bTrace) $this->setDebug(true);
|
||||
//if($bTrace) $this->setDebug(true);
|
||||
}
|
||||
|
||||
public function getTrace()
|
||||
@@ -596,6 +596,22 @@ class Db extends PhpObject
|
||||
return $asResult;
|
||||
}
|
||||
|
||||
public function selectColumn($sTableName, $asColumnNames, $asConstraints)
|
||||
{
|
||||
$sGroupBy = '';
|
||||
if(!is_array($asColumnNames)) $asColumnNames = array($asColumnNames);
|
||||
else $sGroupBy = $asColumnNames[0];
|
||||
|
||||
return $this->selectRows(
|
||||
array(
|
||||
'select' => $asColumnNames,
|
||||
'from' => $sTableName,
|
||||
'constraint'=> $asConstraints
|
||||
),
|
||||
$sGroupBy
|
||||
);
|
||||
}
|
||||
|
||||
public function selectValue($sTableName, $sColumnName, $oConstraints=array())
|
||||
{
|
||||
if(!is_array($oConstraints))
|
||||
@@ -663,6 +679,23 @@ class Db extends PhpObject
|
||||
return array_combine($asKeys, $asValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
/*
|
||||
public function select($asFields='*')
|
||||
{
|
||||
$oSql = new Sql($this, array('select'=>$asFields));
|
||||
return $oSql;
|
||||
}
|
||||
|
||||
public function from($sTable)
|
||||
{
|
||||
$oSql = new Sql($this, array('from'=>$sTable));
|
||||
return $oSql;
|
||||
}
|
||||
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->oConnection;
|
||||
}
|
||||
*/
|
||||
}
|
||||
Reference in New Issue
Block a user