Update database.php
This commit is contained in:
parent
aff12f0e68
commit
71d0872945
|
|
@ -679,7 +679,8 @@ include "root.php";
|
||||||
unset($sql);
|
unset($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($array) {
|
public function delete($delete_array) {
|
||||||
|
|
||||||
//connect to the database if needed
|
//connect to the database if needed
|
||||||
if (!$this->db) {
|
if (!$this->db) {
|
||||||
$this->connect();
|
$this->connect();
|
||||||
|
|
@ -699,9 +700,6 @@ include "root.php";
|
||||||
//debug sql
|
//debug sql
|
||||||
$this->debug["sql"] = true;
|
$this->debug["sql"] = true;
|
||||||
|
|
||||||
//start the atomic transaction
|
|
||||||
//$this->db->beginTransaction();
|
|
||||||
|
|
||||||
//debug info
|
//debug info
|
||||||
//echo "<pre>\n";
|
//echo "<pre>\n";
|
||||||
//print_r($array);
|
//print_r($array);
|
||||||
|
|
@ -709,7 +707,7 @@ include "root.php";
|
||||||
//exit;
|
//exit;
|
||||||
|
|
||||||
//get the current data
|
//get the current data
|
||||||
foreach($array as $table_name => $rows) {
|
foreach($delete_array as $table_name => $rows) {
|
||||||
foreach($rows as $row) {
|
foreach($rows as $row) {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$sql = "select * from ".$table_prefix.$table_name." ";
|
$sql = "select * from ".$table_prefix.$table_name." ";
|
||||||
|
|
@ -719,16 +717,24 @@ include "root.php";
|
||||||
$parameters[$field_name] = $field_value;
|
$parameters[$field_name] = $field_value;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$old_array[$table_name] = $this->execute($sql, $parameters);
|
if (strlen($field_value) > 0) {
|
||||||
|
$results = $this->execute($sql, $parameters, 'row');
|
||||||
|
if (is_array($results)) {
|
||||||
|
$array[$table_name][] = $results;
|
||||||
|
}
|
||||||
|
}
|
||||||
unset($parameters);
|
unset($parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//save the array
|
||||||
|
$old_array = &$array;
|
||||||
|
|
||||||
//start the atomic transaction
|
//start the atomic transaction
|
||||||
$this->db->beginTransaction();
|
$this->db->beginTransaction();
|
||||||
|
|
||||||
//delete the current data
|
//delete the current data
|
||||||
foreach($array as $table_name => $rows) {
|
foreach($delete_array as $table_name => $rows) {
|
||||||
//echo "table: ".$table_name."\n";
|
//echo "table: ".$table_name."\n";
|
||||||
foreach($rows as $row) {
|
foreach($rows as $row) {
|
||||||
if (permission_exists($this->singular($table_name).'_delete')) {
|
if (permission_exists($this->singular($table_name).'_delete')) {
|
||||||
|
|
@ -859,6 +865,7 @@ include "root.php";
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
unset($sql);
|
unset($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
} //delete
|
} //delete
|
||||||
|
|
||||||
public function count() {
|
public function count() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue