

Just another weird PHP function - avsaro
https://github.com/avsaro/MyQuery

======
avsaro
Guys, I have to say that you criticize me a little harsh. But you are
educative anyway, therefore I would not complain. I actually did not use this
script in any project, I sometimes write such scripts just for fun and I
decided to put them on GitHub. I recently change my repo's name to weird-
scripts and I put one more script (this one is a js script). You can see its
new version in this url <http://goo.gl/1g6k6> and I hope that you criticize
this new code too.

------
bbrizzi
It seems pretty weird to design it that way, using a global config. At least
name it some other way to avoid name collisions. Maybe add it as an optional
second parameter and define it as static.

Also, the mysqli extension should be preferred over mysql so it should come
before in the code.

Finally, if your connection fails, $dbconn will be set to false, which is ==
to null in PHP. You should have two checks on this variable: $dbcon === NULL
and $dbconn === false.

------
Pewpewarrows
If nothing else, this snippet is a prime example of why friends don't let
friends work in PHP. It fosters awful development practices that lead to
entire code bases of spaghetti like this.

~~~
joshmanders
You sir. Are correct.

------
ysangkok
Your headline doesn't say much. Why not just write "I wrote a PHP function
that takes an SQL statement, executes it, and returns the result in a PHP
array?"

------
koenigdavidmj
No injection checking, and a memory hog. What could possibly go wrong?

And seriously, what are the chances of having the mysqli stuff but not the
mysql_* functions?

