![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Enjoy. I've written a tutorial database system (for which I was planning on eventually writing some tutorials for :p) if you wanna save some time.
|
|
|
|
|
|
#12 | |
|
Programming Guru
![]() ![]() |
Quote:
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
|
#13 |
|
PFO Founder
![]() ![]() |
i added some things to dbSelect function
![]() [php] function dbSelect($what, $from, $where = "", $order = "") { //////////////////////////////////////////////// // Purpose: This function lets you do a select from the db that you just connected to. // Pre: The coonection has to be made, also you need to send at least what and from // var for this function to run // Example: if you wanted to select all cats from the table called cats: // dbselect("*", "cats", ""); // if you wanted to select all the cats from the tabled called cats that are red: // dbselect("*", "cats", "colour=red"); // Post: Returns the record set. Returns false if it blew up. //////////////////////////////////////////////// if ($where == "" && $order == "") { $sql = "SELECT " . $what . " FROM " . $from . ";"; }elseif ($where != "" && $order == "") { $sql = "SELECT " . $what . " FROM " . $from . " WHERE " . $where . ";"; }elseif ($where == "" && $order != "") { $sql = "SELECT " . $what . " FROM " . $from . " ORDER BY " . $order . ";"; } $res = pg_query($sql); if ($res) { return $res; }else{ return false; } } [/php]
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
|
|
#14 |
|
Programming Guru
![]() ![]() |
thanks for the changes, makes more sence having it setup like that.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#15 |
|
PFO Founder
![]() ![]() |
i should have one more thing added to that for when both $where and $order are there. im just missing an extra if ($where != "" && $order != "") and then have the sql for that
![]()
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
|
|
#16 |
|
Programming Guru
![]() |
I added some things to big_k's code, it didn't have code for the situation of there being a where and order by clause.
[php] function dbSelect($what, $from, $where = "", $order = "") { //////////////////////////////////////////////// // Purpose: This function lets you do a select from the db that you just connected to. // Pre: The coonection has to be made, also you need to send at least what and from // var for this function to run // Example: if you wanted to select all cats from the table called cats: // dbselect("*", "cats", ""); // if you wanted to select all the cats from the tabled called cats that are red: // dbselect("*", "cats", "colour=red"); // Post: Returns the record set. Returns false if it blew up. //////////////////////////////////////////////// if ($where == "" && $order == "") { $sql = "SELECT " . $what . " FROM " . $from . ";"; }elseif ($where != "" && $order == "") { $sql = "SELECT " . $what . " FROM " . $from . " WHERE " . $where . ";"; }elseif ($where == "" && $order != "") { $sql = "SELECT " . $what . " FROM " . $from . " ORDER BY " . $order . ";"; }else { $sql = "select {$what} from {$from} where {$where} order by {$order}"; } $res = pg_query($sql); if ($res) { return $res; }else{ return false; } } [/php]
__________________
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|