Well right now I am trying to design a database system with adapters such that you can use generic database objects such as Database(connection), Statement, PreparedStatement, ResultSet and RowSet with same method signatures no matter whether you use MySQLi, PDO, PgSQL or SQLite etc. The problem I am having right now is that, well, since my classes are namespaced when I use pg sql functions I get errors like this:
Call to undefined function Mysidia\\Resource\\Database\\Adapter\\pg_connect() in /home/mysidia/public_html/site/framework/database/adapter/postgresqladapter.php on line 49
So here are my questions. First of all, I thought global functions are automatically imported or that at least its name resolution should start at the root global namespace. Did PHP change this behavior in version 5.4 or that was I mistaken in the very first place?
Second, is there a way to import functions by importing extensions with prefixes into the current namespace? I can get away with by adding a leading backslash to go back to the global namespace, but I hate using leading backslashes as they are one of the ugliest syntax I’ve ever seen, why does PHP’s namespace resolution work so differently from other languages? sigh
At last, even if I end up using the ugly leading backslash like \pg_connect and \pg_query, is this trick even gonna work with earlier versions like PHP 5.3 as my software’s lowest requirement is PHP 5.3(though I run my own PHP 5.4 server, it does become somewhat complex to compensate for PHP 5.3 users, but hey its still way better than having to worry about compatibility with outdated PHP 5.2 lol).
Thx.