Started adding support for Mongo in the Model class. Also removed fetchAll and fetchColumn methods, all data is returned as an associative array for consistency and to simplify the fetching logic.

This commit is contained in:
Josh Sherman 2010-10-31 14:34:39 -04:00
parent fce848e9bb
commit 795594a391
3 changed files with 74 additions and 83 deletions

View file

@ -196,14 +196,14 @@ class Database_PDO_Common extends Database_Common
}
/**
* Fetch a single row from the database
* Fetch records from the database
*
* @param string $sql statement to be executed
* @param array $input_parameters optional key/values to be bound
* @param string $return_type optional type of return set
* @return mixed based on return type
*/
public function fetch($sql = null, $input_parameters = null, $return_type = null)
public function fetch($sql = null, $input_parameters = null)
{
$this->open();
@ -213,49 +213,10 @@ class Database_PDO_Common extends Database_Common
}
// Pulls the results based on the type
$results = false;
switch ($return_type)
{
case 'column':
$results = $this->results->fetchColumn(0);
break;
case 'all':
$results = $this->results->fetchAll(PDO::FETCH_ASSOC);
break;
default:
$results = $this->results->fetch(PDO::FETCH_ASSOC);
break;
}
$results = $this->results->fetchAll(PDO::FETCH_ASSOC);
return $results;
}
/**
* Fetch a single column from the database
*
* This method assumes you want the first column in your select. If you
* need 2 or more columns you should simply use fetch().
*
* @param string $sql statement to be executed
* @param array $input_parameters optional key/values to be bound
* @return string
*/
public function fetchColumn($sql = null, $input_parameters = null)
{
return $this->fetch($sql, $input_parameters, 'column');
}
/**
* Fetches all rows as an array
*
* @param string $sql statement to be executed
* @param array $input_parameters optional key/values to be bound
* @return array
*/
public function fetchAll($sql = null, $input_parameters = null)
{
return $this->fetch($sql, $input_parameters, 'all');
}
}
?>