Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with dibi::getConnection()->getDatabaseInfo()->getTables() on empty db (postgre driver) #4

Closed
Edke opened this issue Jan 22, 2010 · 1 comment

Comments

@Edke
Copy link

Edke commented Jan 22, 2010

There is a problem getting array of tables if database is empty while using postgre driver.

Problem is in postgre.php in GetTables(). If there are no rows in resultSet, pg_fetch_all() returns FALSE . And this cause problems in DibiDatabaseInfo.php in init() method on line 115. Foreach expects it to be array instead and it throws warning 'Invalid argument supplied for foreach()'.

fix:


diff --git a/libs/dibi/drivers/postgre.php b/libs/dibi/drivers/postgre.php
index 6fbb560..f07d138 100644
--- a/libs/dibi/drivers/postgre.php
+++ b/libs/dibi/drivers/postgre.php
@@ -426,7 +426,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver
                ");
                $res = pg_fetch_all($this->resultSet);
                $this->free();
-               return $res;
+               return ($res === false ) ? array() : $res;
        }
@nette
Copy link

nette commented Jan 23, 2010

fixed

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant