Merge pull request #28668 from atm-john/fix_element_type_part_04
NEW : Factoring and Fix external module elementType limit - Part 04
This commit is contained in:
commit
2cbeca6d4f
1 changed files with 18 additions and 13 deletions
|
|
@ -381,10 +381,11 @@ abstract class DoliDB implements Database
|
|||
{
|
||||
$sql .= ' LIMIT 1';
|
||||
|
||||
$res = $this->query($sql);
|
||||
if ($res) {
|
||||
$obj = $this->fetch_object($res);
|
||||
$resql = $this->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $this->fetch_object($resql);
|
||||
if ($obj) {
|
||||
$this->free($resql);
|
||||
return $obj;
|
||||
} else {
|
||||
return 0;
|
||||
|
|
@ -395,24 +396,28 @@ abstract class DoliDB implements Database
|
|||
}
|
||||
|
||||
/**
|
||||
* Return all results from query as an array of objects
|
||||
* Note : This method executes a given SQL query and retrieves all row of results as an array of objects. It should only be used with SELECT queries
|
||||
* be careful with this method use it only with some limit of results to avoid performances loss.
|
||||
* Return all results from query as an array of objects. Using this is a bad practice and is discouraged.
|
||||
* Note : It should only be used with SELECT queries and with a limit. If you are not able to defined/know what can be the limit, it
|
||||
* just means this function is not what you need. Do not use it.
|
||||
*
|
||||
* @param string $sql The sql query string
|
||||
* @return bool|array Result
|
||||
* @deprecated
|
||||
* @param string $sql The sql query string. Must end with "... LIMIT x"
|
||||
* @return bool|array Result
|
||||
*/
|
||||
public function getRows($sql)
|
||||
{
|
||||
$res = $this->query($sql);
|
||||
if ($res) {
|
||||
if (! preg_match('/LIMIT \d+$/', $sql)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$resql = $this->query($sql);
|
||||
if ($resql) {
|
||||
$results = array();
|
||||
if ($this->num_rows($res) > 0) {
|
||||
while ($obj = $this->fetch_object($res)) {
|
||||
if ($this->num_rows($resql) > 0) {
|
||||
while ($obj = $this->fetch_object($resql)) {
|
||||
$results[] = $obj;
|
||||
}
|
||||
}
|
||||
$this->free($resql);
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue