From 7695657e4f1be1c1d8e19861390ace9c782cf5aa Mon Sep 17 00:00:00 2001 From: franzz Date: Fri, 1 Mar 2019 18:11:11 +0100 Subject: [PATCH] add selectColumn function --- inc/db.php | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/inc/db.php b/inc/db.php index 5b4741a..c405430 100644 --- a/inc/db.php +++ b/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() @@ -595,6 +595,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()) { @@ -663,6 +679,23 @@ class Db extends PhpObject return array_combine($asKeys, $asValues); } } -} - -?> \ No newline at end of file + + /* + 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; + } + */ +} \ No newline at end of file