Index: trunk/core/kernel/db/dbitem.php
===================================================================
diff -u -r2460 -r2711
--- trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 2460)
+++ trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 2711)
@@ -248,19 +248,24 @@
$this->ID = $id;
$q = $this->GetSelectSQL().' WHERE '.(isset($keys_sql) ? $keys_sql : $this->GetKeyClause('load'));
- if ($this->DisplayQueries) {
- echo get_class($this)." Load SQL: $q
";
- }
- $this->FieldValues = array_merge_recursive2( $this->FieldValues, $this->Conn->GetRow($q) );
- if ($this->FieldValues === false) {
- //Error handling could be here
+ $field_values = $this->Conn->GetRow($q);
+ if($field_values)
+ {
+ $this->FieldValues = array_merge_recursive2($this->FieldValues, $field_values);
+ }
+ else
+ {
+ $this->Loaded = false;
return false;
}
- if (isset($keys_sql)) {
- $this->setID($this->FieldValues[$this->IDField]);
+
+ if( isset($keys_sql) )
+ {
+ $this->setID( $this->FieldValues[$this->IDField] );
}
- else {
+ else
+ {
$this->setID($id);
}
@@ -354,15 +359,7 @@
$sql.= sprintf(' WHERE %s', $this->GetKeyClause('update')); //Adding WHERE clause with Primary Key
- if ($this->DisplayQueries) echo "Sql: $sql
";
-
- if ($this->Conn->ChangeQuery($sql) === false) { //Executing query and checking results
- if ($this->DisplayQueries)
- {
- echo "Error executing statement: ".$adodbConnection->ErrorMsg()."
";
- }
- return false;
- }
+ if( $this->Conn->ChangeQuery($sql) === false ) return false;
$affected = $this->Conn->getAffectedRows();
if (!$system_update && $affected == 1){
@@ -647,15 +644,7 @@
$sql = sprintf('INSERT INTO %s (%s) VALUES (%s)', $this->TableName, $fields_sql, $values_sql); //Formatting query
//Executing the query and checking the result
-
- if ($this->Conn->ChangeQuery($sql) === false)
- {
- if($this->DisplayQueries)
- {
- echo "Error executing statement: ".$this->Conn->getErrorMsg().'
';
- }
- return false;
- }
+ if($this->Conn->ChangeQuery($sql) === false) return false;
$insert_id = $this->Conn->getInsertID();
if($insert_id == 0) $insert_id = $this->FieldValues[$this->IDField];
@@ -675,19 +664,14 @@
* @access public
* @return bool
*/
- function Delete($id=null)
+ function Delete($id = null)
{
- if( isset($id) ) {
- $this->setID($id);
- }
+ if( isset($id) ) $this->setID($id);
if( !$this->raiseEvent('OnBeforeItemDelete') ) return false;
$q = 'DELETE FROM '.$this->TableName.' WHERE '.$this->GetKeyClause('Delete');
- if ($this->DisplayQueries)
- {
- echo get_class($this).' Delete SQL: '.$q.'
';
- }
+
$ret = $this->Conn->ChangeQuery($q);
$this->setModifiedFlag();