add selectColumn function
This commit is contained in:
39
inc/db.php
39
inc/db.php
@@ -3,7 +3,7 @@
|
|||||||
/**
|
/**
|
||||||
* MySql query manager and generator
|
* MySql query manager and generator
|
||||||
* @author franzz
|
* @author franzz
|
||||||
* @version 2.0
|
* @version 2.1
|
||||||
*/
|
*/
|
||||||
class Db extends PhpObject
|
class Db extends PhpObject
|
||||||
{
|
{
|
||||||
@@ -98,7 +98,7 @@ class Db extends PhpObject
|
|||||||
public function setTrace($bTrace=true)
|
public function setTrace($bTrace=true)
|
||||||
{
|
{
|
||||||
$this->bTrace = $bTrace;
|
$this->bTrace = $bTrace;
|
||||||
if($bTrace) $this->setDebug(true);
|
//if($bTrace) $this->setDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTrace()
|
public function getTrace()
|
||||||
@@ -596,6 +596,22 @@ class Db extends PhpObject
|
|||||||
return $asResult;
|
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())
|
public function selectValue($sTableName, $sColumnName, $oConstraints=array())
|
||||||
{
|
{
|
||||||
if(!is_array($oConstraints))
|
if(!is_array($oConstraints))
|
||||||
@@ -663,6 +679,23 @@ class Db extends PhpObject
|
|||||||
return array_combine($asKeys, $asValues);
|
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