Version 0.9.5 beta - updated selectDatasetByFieldWhere with sort order and removed numeric array keys.
This commit is contained in:
@@ -110,11 +110,12 @@ abstract class Db implements IDb
|
||||
|
||||
/**
|
||||
* @param array $fieldWhere
|
||||
* @return mixed|void
|
||||
* @param false $sortOrder
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function selectDatasetByFieldWhere($fieldWhere = array())
|
||||
public function selectDatasetByFieldWhere($fieldWhere = array(), $sortOrder = false)
|
||||
{
|
||||
return Pdo::selectDatasetByFieldAndValue(self::$table['table'], $fieldWhere);
|
||||
return Pdo::selectDatasetByFieldAndValue(self::$table['table'], $fieldWhere, $sortOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,9 +54,17 @@ final class Pdo extends Mysql implements IPdo
|
||||
return $query->fetchAll();
|
||||
}
|
||||
|
||||
public static function selectDatasetByFieldAndValue($tablename = self::PLACE_TABLE_NAME, $fieldAndValue = array() )
|
||||
public static function selectDatasetByFieldAndValue($tablename = self::PLACE_TABLE_NAME, $fieldAndValue = array(), $sortOrder = false )
|
||||
{
|
||||
$result = parent::getInstance( self::getSettingsSection() )->getConn()->query("SELECT * FROM " . $tablename . " WHERE " . $fieldAndValue['name'] . " = '" . $fieldAndValue['value'] . "';");
|
||||
if(is_array($sortOrder))
|
||||
{
|
||||
$result = parent::getInstance( self::getSettingsSection() )->getConn()->query("SELECT * FROM " . $tablename . " WHERE " . $fieldAndValue['name'] . " = '" . $fieldAndValue['value'] . " ORDER BY ".$sortOrder['field']." ". $sortOrder['order'] ."';");
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = parent::getInstance( self::getSettingsSection() )->getConn()->query("SELECT * FROM " . $tablename . " WHERE " . $fieldAndValue['name'] . " = '" . $fieldAndValue['value'] . "';");
|
||||
}
|
||||
|
||||
$result = $result->fetchAll();
|
||||
$resultset = [];
|
||||
if(array_key_exists(0, $result))
|
||||
|
||||
@@ -66,9 +66,10 @@ interface IDb
|
||||
* @desc will return a result array from the searched where field from the database
|
||||
* containing the entire dataset rows
|
||||
* @param array $fieldWhere
|
||||
* @param false $sortOrder
|
||||
* @return mixed
|
||||
*/
|
||||
public function selectDatasetByFieldWhere( $fieldWhere = array() );
|
||||
public function selectDatasetByFieldWhere( $fieldWhere = array(), $sortOrder = false );
|
||||
|
||||
/**
|
||||
* @desc selects a row by the fieldname and the given value, should be
|
||||
|
||||
Reference in New Issue
Block a user