mirror of
https://github.com/dg/dibi.git
synced 2025-08-08 07:06:52 +02:00
- added DibiDataSource::fetch(), fetchAll(), fetchSingle(), fetchPairs() & fetchAssoc()
This commit is contained in:
@@ -238,6 +238,21 @@ class DibiFluent extends DibiObject implements IDataSource
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the dibi connection.
|
||||
* @return DibiConnection
|
||||
*/
|
||||
final public function getConnection()
|
||||
{
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************* executing ****************d*g**/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generates and executes SQL query.
|
||||
* @param mixed what to return?
|
||||
@@ -255,7 +270,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
||||
/**
|
||||
* Generates, executes SQL query and fetches the single row.
|
||||
* @return DibiRow|FALSE array on success, FALSE if no next record
|
||||
* @throws DibiException
|
||||
*/
|
||||
public function fetch()
|
||||
{
|
||||
@@ -298,11 +312,8 @@ class DibiFluent extends DibiObject implements IDataSource
|
||||
|
||||
/**
|
||||
* Fetches all records from table and returns associative tree.
|
||||
* Associative descriptor: assoc1,#,assoc2,=,assoc3,@
|
||||
* builds a tree: $data[assoc1][index][assoc2]['assoc3']->value = {record}
|
||||
* @param string associative descriptor
|
||||
* @return array
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function fetchAssoc($assoc)
|
||||
{
|
||||
@@ -316,7 +327,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
||||
* @param string associative key
|
||||
* @param string value
|
||||
* @return array
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function fetchPairs($key = NULL, $value = NULL)
|
||||
{
|
||||
@@ -338,6 +348,18 @@ class DibiFluent extends DibiObject implements IDataSource
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generates and prints SQL query or it's part.
|
||||
* @param string clause name
|
||||
* @return bool
|
||||
*/
|
||||
public function test($clause = NULL)
|
||||
{
|
||||
return $this->connection->test($this->_export($clause));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@@ -350,14 +372,27 @@ class DibiFluent extends DibiObject implements IDataSource
|
||||
|
||||
|
||||
|
||||
/********************* exporting ****************d*g**/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generates and prints SQL query or it's part.
|
||||
* @param string clause name
|
||||
* @return bool
|
||||
* @return DibiDataSource
|
||||
*/
|
||||
public function test($clause = NULL)
|
||||
public function toDataSource()
|
||||
{
|
||||
return $this->connection->test($this->_export($clause));
|
||||
return new DibiDataSource($this->connection->sql($this->_export()), $this->connection);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns SQL query.
|
||||
* @return string
|
||||
*/
|
||||
final public function __toString()
|
||||
{
|
||||
return $this->connection->sql($this->_export());
|
||||
}
|
||||
|
||||
|
||||
@@ -411,38 +446,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return DibiDataSource
|
||||
*/
|
||||
public function toDataSource()
|
||||
{
|
||||
return new DibiDataSource($this->connection->sql($this->_export()), $this->connection);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns SQL query.
|
||||
* @return string
|
||||
*/
|
||||
final public function __toString()
|
||||
{
|
||||
return $this->connection->sql($this->_export());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the dibi connection.
|
||||
* @return DibiConnection
|
||||
*/
|
||||
final public function getConnection()
|
||||
{
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user