HEX
Server: Apache/2.4.6 (CentOS) mpm-itk/2.4.7-04 mod_fcgid/2.3.9 PHP/5.4.16
System: Linux dvm.vladweb.ru 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: region-gk.ru (1016)
PHP: 8.2.27
Disabled: NONE
Upload Files
File: /home/bk/efi/eficenter.ru/core/class.TObject.php
<?php

/**
	!!! ����� ���� �� ����� � �� �������, ����� �� �������� ����� �� ������!!!
*/


class TObject {
 var $_tbl 			= '';
 var $_tbl_key 		= '';
 var $_error 		= '';

 function TObject( $table, $key ) {
	$this->_tbl 		= $table;
	$this->_tbl_key 	= $key;
 }

 function getError() {
  return $this->_error;
 }

 function bind( $hash ) {
  if (!is_array( $hash )) {
   $this->_error = get_class( $this )."::bind failed.";
   return false;
  } else {
   bindHashToObject( $hash, $this );
   return true;
  }
 }

 function load( $oid=null , $strip = true) {
  $k = $this->_tbl_key;
  if ($oid) {
   $this->$k = intval( $oid );
  }
  $oid = $this->$k;
  if ($oid === null) {
   return false;
  }
  $sql = "SELECT * FROM $this->_tbl WHERE $this->_tbl_key=$oid";
  return db_loadObject( $sql, $this, false, $strip );
 }

 function check() {
  return NULL;
 }

 function _clone() {
  $_key 			= $this->_tbl_key;
  $newObj 			= $this;
  $newObj->$_key 	= '';
  return $newObj;
 }

 function store( $updateNulls = false ) {
  $msg = $this->check();
  if( $msg ) {
   return get_class( $this )."::store-check failed<br />$msg";
  }
  $k = $this->_tbl_key;
  if( $this->$k ) {
   $ret = db_updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls );
   return true;
  } else {
   $ret = db_insertObject( $this->_tbl, $this, $this->_tbl_key );
   return true;
  }
  if( !$ret ) {
   //return get_class( $this )."::store failed <br />" . db_error();
   return false;
  } else {
   return true;
  }
 }

 function delete( $oid=null ) {
  $k = $this->_tbl_key;
  if ($oid) {
   $this->$k = intval( $oid );
  }
  $sql = "DELETE FROM $this->_tbl WHERE $this->_tbl_key = '".$this->$k."'";
  db_exec( $sql );
  if (!db_affected_rows() > 0) {
   return false;
  } else {
   return true;
  }
 }
}

?>