Connection::getObject(), Errores solucionados

This commit is contained in:
Juan Ferrer Toribio 2017-05-30 15:27:25 +02:00
parent dc88a10f28
commit 363f1718be
4 changed files with 46 additions and 3 deletions

View File

@ -142,13 +142,32 @@ class Connection
return NULL;
}
/**
* Gets the first row value of the first column from a result.
*
* @param resource $result The database result
*
* @return object An object with the first row, %NULL if error
**/
function getObjectFromResult ($result)
{
if ($result)
{
$row = $result->fetch_object ();
$result->free ();
return $row;
}
return NULL;
}
/**
* Gets the first row value of the first column from a result.
*
* @param resource $result The database result
*
* @return mixed The value or %NULL if error
* @return mixed The value or %NULL if error
**/
function getValueFromResult ($result)
{
@ -181,6 +200,20 @@ class Connection
return $this->getRowFromResult ($result);
}
/**
* Executes the query and gets it's first row.
*
* @param string $query The SQL query
* @param mixed[] $params The query parameters
*
* @return object An object with the first row, %NULL if error
**/
function getObject ($query, $params = NULL)
{
$result = $this->query ($query, $params);
return $this->getObjectFromResult ($result);
}
/**
* Executes the query and gets the first value of the first row.
*

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
php-vn-lib (1.309-deb8) stable; urgency=low
php-vn-lib (2.1.2) stable; urgency=low
* Initial Release.

View File

@ -49,6 +49,16 @@ class App
return $this->name;
}
/**
* Returns the configuration object.
*
* @return The config object
**/
function getConf ()
{
return $this->conf;
}
/**
* Initializes Application. Should be the first called function in any
* application that uses this class.

View File

@ -52,7 +52,7 @@ abstract class Method
return FALSE;
foreach ($params as $param)
if (empty ($map[$param]))
if (!isset ($map[$param]))
{
return FALSE;
break;