/ Published in: PHP
This is a start for a table management class. It will select, update, delete, and insert. I'd like to add more functionality on the update and insert functions but it will require some more work (I need to figure out how to split var $3, the columns). Any alterations or additions are welcome.
Expand |
Embed | Plain Text
class $1 extends db { // SQL Table: ${2:tbl_$1} // Columns: id,$3 function $1 (){ } public function get$1(){ db::connect(); \$query = "SELECT id,$3 FROM $2"; return \$result; } public function get$1instance(\$id){ db::connect(); \$query = "SELECT id,$3 FROM $2 WHERE id=" . \$id; return \$result; } public function insert$1(\$$1details){ db::connect(); \$query = "INSERT INTO $2 ($3) VALUES ('" \$$1details[$4] . "'" . $0 ")"; } public function delete$1(\$id){ db::connect(); \$query = "DELETE FROM $2 WHERE id = " . \$id; return \$id; } public function update$1(\$id,\$$1details){ db::connect(); \$query = "UPDATE $2 SET $4 = '" . \$$1details[$4] . "' WHERE id = " . \$id; return \$id; } }
You need to login to post a comment.
