/** Radix_SQL_Record Model Constructor */ function __construct($t = null, $k = null, $v = null) { // Do Nothing if ($t == null) { return; } // Copy Properties from Array Keys if (is_array($t) && $k == null) { $this->_data = $t; return; } if (is_numeric($t) && $k == null && $v == null) { $v = $t; // Move the ID to Value $t = $this->_table; $k = $this->_pkcol; } $this->_table = $t; $this->_pkcol = $k; $this->_pkval = $v; // Detect Object Properties from Table if not Specified // if (!isset($this->_properties)) { // $this->_properties = array(); // $d = $db->describeTable($this->_table); // foreach ($d as $k=>$v) { // $this->_properties[] = $k; // if (!isset($this->$k)) { // $this->$k = null; // } // } // } // Load Database Record if (is_numeric($this->_pkval) && intval($this->_pkval) > 0) { //$db = Zend_Registry::get('db'); // $this->id = intval($x); // $sql = sprintf("select * from \"%s\" where id='%d'",$this->_table,intval($x)); // $x = $db->fetchRow($sql); // if (is_object($x)) { // $p = get_object_vars($x); // foreach ($p as $k=>$v) { // $this->$k = stripslashes($x->$k); // } // } $sql = "SELECT * FROM {$this->_table} WHERE {$this->_pkcol} = ?"; // Radix::dump($sql); $this->_data = radix_db_sql::fetch_row($sql, array($this->_pkval)); } // Copy properties from Given object to me! // if (is_object($x)) { // $p = get_object_vars($x); // foreach ($p as $k=>$v) { // $this->$k = $x->$k; // } // return; // } }