瀏覽代碼

new method for database object

luis daniel lucio quiroz 11 年之前
父節點
當前提交
75e7ba7b8c
共有 1 個文件被更改,包括 15 次插入1 次删除
  1. 15 1
      resources/classes/database.php

+ 15 - 1
resources/classes/database.php

@@ -22,6 +22,7 @@
 
 	Contributor(s):
 	Mark J Crane <[email protected]>
+	Luis Daniel Lucio Quiroz <[email protected]>
 */
 include "root.php";
 
@@ -341,6 +342,19 @@ include "root.php";
 					}
 			}
 
+			// Use this function to execute complex queries
+			public function execute(){
+					//echo $sql;
+					$prep_statement = $this->db->prepare($sql);
+					if ($prep_statement) {
+						$prep_statement->execute();
+						return $prep_statement->fetchAll(PDO::FETCH_ASSOC);
+					}
+					else {
+						return false;
+					}
+			}
+
 			public function add(){
 				//connect to the database if needed
 					if (!$this->db) {
@@ -568,4 +582,4 @@ if (!function_exists('php_right')) {
 	$database->add();
 	print_r($database->result);
 */
-?>
+?>