| 1 |
<?php |
<?php |
| 2 |
|
/** |
| 3 |
|
* @package Mambo Open Source |
| 4 |
|
* @subpackage Database |
| 5 |
|
* @copyright (C) 2005 - 2006 Mambo Foundation Inc. |
| 6 |
|
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
| 7 |
|
* |
| 8 |
|
* Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure |
| 9 |
|
* that Mambo remained free Open Source software owned and managed by the community. |
| 10 |
|
* Mambo is Free Software |
| 11 |
|
*/ |
| 12 |
|
|
| 13 |
/** |
/** |
| 14 |
* Database connector class |
* Database connector class |
|
* @subpackage Database |
|
|
* @package Mambo |
|
| 15 |
*/ |
*/ |
| 16 |
class database { |
class database { |
| 17 |
/** @var string Internal variable to hold the query sql */ |
/** @var string Internal variable to hold the query sql */ |
| 30 |
var $_debug=0; |
var $_debug=0; |
| 31 |
/** @var array A log of queries */ |
/** @var array A log of queries */ |
| 32 |
var $_log=array(); |
var $_log=array(); |
| 33 |
|
/** @var string Null date */ |
| 34 |
|
var $_null_date='0000-00-00 00:00:00'; |
| 35 |
|
|
| 36 |
/** |
/** |
| 37 |
* Database object constructor |
* Database object constructor |
| 56 |
include $basePath . '/../offline.php'; |
include $basePath . '/../offline.php'; |
| 57 |
exit(); |
exit(); |
| 58 |
} |
} |
| 59 |
|
|
| 60 |
|
function getNullDate () { |
| 61 |
|
return $this->_null_date; |
| 62 |
|
} |
| 63 |
/** |
/** |
| 64 |
* @param int |
* @param int |
| 65 |
*/ |
*/ |
| 128 |
function replacePrefix ($sql, $prefix='#__') { |
function replacePrefix ($sql, $prefix='#__') { |
| 129 |
$done = ''; |
$done = ''; |
| 130 |
while (strlen($sql)) { |
while (strlen($sql)) { |
| 131 |
if ($double = preg_match('/\"([^\\\"]|\\.)*"/', $sql,$matches_double,PREG_OFFSET_CAPTURE) OR |
$single = preg_match("/\'([^\\\']|\\.)*'/", $sql,$matches_single,PREG_OFFSET_CAPTURE); |
| 132 |
$single = preg_match("/\'([^\\\']|\\.)*'/", $sql,$matches_single,PREG_OFFSET_CAPTURE)) { |
if ($double = preg_match('/\"([^\\\"]|\\.)*"/', $sql,$matches_double,PREG_OFFSET_CAPTURE) OR $single) { |
| 133 |
if ($single == 0 OR ($double AND $matches_double[0][1] < $matches_single[0][1])) { |
if ($single == 0 OR ($double AND $matches_double[0][1] < $matches_single[0][1])) { |
| 134 |
$done .= str_replace($prefix, $this->_table_prefix, substr($sql,0,$matches_double[0][1])).$matches_double[0][0]; |
$done .= str_replace($prefix, $this->_table_prefix, substr($sql,0,$matches_double[0][1])).$matches_double[0][0]; |
| 135 |
$sql = substr($sql,$matches_double[0][1]+strlen($matches_double[0][0])); |
$sql = substr($sql,$matches_double[0][1]+strlen($matches_double[0][0])); |
| 223 |
return "<div style=\"background-color:#FFFFCC\" align=\"left\">$buf</div>"; |
return "<div style=\"background-color:#FFFFCC\" align=\"left\">$buf</div>"; |
| 224 |
} |
} |
| 225 |
/** |
/** |
| 226 |
* @return int The number of rows returned from the most recent query. |
* @return int The number of rows returned from the most recent query - SELECT only |
| 227 |
*/ |
*/ |
| 228 |
function getNumRows( $cur=null ) { |
function getNumRows( $cur=null ) { |
| 229 |
return mysql_num_rows( $cur ? $cur : $this->_cursor ); |
return mysql_num_rows( $cur ? $cur : $this->_cursor ); |
| 230 |
} |
} |
| 231 |
|
|
| 232 |
/** |
/** |
| 233 |
|
* @return int The number of rows affected by the most recent query - INSERT, UPDATE, DELETE |
| 234 |
|
*/ |
| 235 |
|
function getAffectedRows( ) { |
| 236 |
|
return mysql_affected_rows( $this->_resource ); |
| 237 |
|
} |
| 238 |
|
|
| 239 |
|
/** |
| 240 |
* Load an array of retrieved database objects or values |
* Load an array of retrieved database objects or values |
| 241 |
* @param int Database cursor |
* @param int Database cursor |
| 242 |
* @param string The field name of a primary key |
* @param string The field name of a primary key |
| 560 |
} |
} |
| 561 |
} |
} |
| 562 |
|
|
|
|
|
| 563 |
/** |
/** |
| 564 |
* mosDBTable Abstract Class. |
* mosDBAbstractRow Abstract Class. |
| 565 |
* @abstract |
* @abstract |
| 566 |
* @package Mambo |
* @package Mambo |
| 567 |
* @subpackage Database |
* @subpackage Database |
| 569 |
* Parent classes to all database derived objects. Customisation will generally |
* Parent classes to all database derived objects. Customisation will generally |
| 570 |
* not involve tampering with this object. |
* not involve tampering with this object. |
| 571 |
* @package Mambo |
* @package Mambo |
| 572 |
* @author Andrew Eddie <eddieajau@users.sourceforge.net |
* @author Martin Brampton counterpoint@mambo-foundation.org |
| 573 |
*/ |
*/ |
| 574 |
class mosDBTable { |
class mosDBAbstractRow { |
| 575 |
/** @var string Name of the table in the db schema relating to child class */ |
/** @var string Name of the table in the db schema relating to child class */ |
| 576 |
var $_tbl = ''; |
var $_tbl = ''; |
| 577 |
/** @var string Name of the primary key field in the table */ |
/** @var string Name of the primary key field in the table */ |
| 578 |
var $_tbl_key = ''; |
var $_tbl_key = ''; |
| 579 |
/** @var string Error message */ |
/** @var string Error message */ |
| 580 |
var $_error = ''; |
var $_error = ''; |
|
/** @var mosDatabase Database connector */ |
|
|
var $_db = null; |
|
| 581 |
|
|
| 582 |
/** |
/** |
| 583 |
* Object constructor to set table and key field |
* Object constructor to set table and key field |
| 586 |
* @param string $table name of the table in the db schema relating to child class |
* @param string $table name of the table in the db schema relating to child class |
| 587 |
* @param string $key name of the primary key field in the table |
* @param string $key name of the primary key field in the table |
| 588 |
*/ |
*/ |
| 589 |
function mosDBTable( $table, $key, &$db ) { |
function mosDBAbstractRow ($table='', $keyname='id', $db='') { |
| 590 |
$this->_tbl = $table; |
if ($table) $this->_tbl = $table; |
| 591 |
$this->_tbl_key = $key; |
else $this->_tbl = $this->tableName(); |
| 592 |
$this->_db =& $db; |
$this->_tbl_key = $keyname; |
| 593 |
|
if (is_object($db)) $this->_db = $db; |
| 594 |
|
} |
| 595 |
|
|
| 596 |
|
/** |
| 597 |
|
* generic check method |
| 598 |
|
* |
| 599 |
|
* can be overloaded/supplemented by the child class |
| 600 |
|
* @return boolean True if the object is ok |
| 601 |
|
*/ |
| 602 |
|
function check() { |
| 603 |
|
return true; |
| 604 |
|
} |
| 605 |
|
|
| 606 |
|
/** |
| 607 |
|
* Checks if this object lacks the property given by the parameter |
| 608 |
|
* @param string The name of the property |
| 609 |
|
* @return bool |
| 610 |
|
*/ |
| 611 |
|
function lacks( $property ) { |
| 612 |
|
$thisclass = get_class($this); |
| 613 |
|
if (array_key_exists( $property, get_class_vars($thisclass) )) return false; |
| 614 |
|
$this->_error = T_(sprintf('WARNING: %s does not support %s.', $thisclass, $property)); |
| 615 |
|
return true; |
| 616 |
|
} |
| 617 |
|
|
| 618 |
|
/** |
| 619 |
|
/* Move a database row object up or down through the ordering |
| 620 |
|
/* @param int positive to move up, negative to move down |
| 621 |
|
/* @param string Additional conditions on the WHERE clause to limit the effect |
| 622 |
|
*/ |
| 623 |
|
function move( $direction, $where='' ) { |
| 624 |
|
$compops = array (-1 => '<', 0 => '=', 1 => '>'); |
| 625 |
|
$relation = $compops[($direction>0)-($direction<0)]; |
| 626 |
|
$ordering = ($relation == '<' ? 'DESC' : 'ASC'); |
| 627 |
|
$k = $this->_tbl_key; |
| 628 |
|
$o1 = $this->ordering; |
| 629 |
|
$k1 = $this->$k; |
| 630 |
|
$database = isset($this->_db) ? $this->_db : mamboDatabase::getInstance(); |
| 631 |
|
$sql = "SELECT $k, ordering FROM $this->_tbl WHERE ordering $relation $o1"; |
| 632 |
|
$sql .= ($where ? "\n AND $where" : '').' ORDER BY ordering '.$ordering.' LIMIT 1'; |
| 633 |
|
$database->setQuery( $sql ); |
| 634 |
|
if ($database->loadObject($row)) { |
| 635 |
|
$o2 = $row->ordering; |
| 636 |
|
$k2 = $row->$k; |
| 637 |
|
$sql = "UPDATE $this->_tbl SET ordering = (ordering=$o1)*$o2 + (ordering=$o2)*$o1 WHERE $k = $k1 OR $k = $k2"; |
| 638 |
|
$database->doSQL($sql); |
| 639 |
|
} |
| 640 |
} |
} |
| 641 |
|
/** |
| 642 |
|
* Compacts the ordering sequence of the selected records |
| 643 |
|
* @param string Additional conditions on WHERE clause to limit ordering to a particular subset of records |
| 644 |
|
*/ |
| 645 |
|
function updateOrder( $where='', $cfid=null, $order=null ) { |
| 646 |
|
if ($this->lacks('ordering')) return false; |
| 647 |
|
$k = $this->_tbl_key; |
| 648 |
|
if ($this->_tbl == "#__content_frontpage") $order2 = ", content_id DESC"; |
| 649 |
|
else $order2 = ""; |
| 650 |
|
|
| 651 |
|
$database = isset($this->_db) ? $this->_db : mamboDatabase::getInstance(); |
| 652 |
|
|
| 653 |
|
if (!is_null($cfid) AND !is_null($order)) { |
| 654 |
|
foreach ($cfid as $i=>$id) { |
| 655 |
|
$o = intval($order[$i]); |
| 656 |
|
$set[] = "(id=$id)*$o"; |
| 657 |
|
} |
| 658 |
|
$sql = "UPDATE $this->_tbl SET ordering = ".implode(' + ', $set).' WHERE id IN ('.implode(',', $cfid).')'; |
| 659 |
|
$database->doSQL($sql); |
| 660 |
|
} |
| 661 |
|
|
| 662 |
|
$sql = "SELECT $k, ordering FROM $this->_tbl " |
| 663 |
|
. ($where ? "\nWHERE $where" : '') |
| 664 |
|
. "\nORDER BY ordering$order2"; |
| 665 |
|
$database->setQuery($sql); |
| 666 |
|
if (!$rows = $database->loadObjectList()) { |
| 667 |
|
$this->_error = $database->getErrorMsg(); |
| 668 |
|
return false; |
| 669 |
|
} |
| 670 |
|
$i = 1; |
| 671 |
|
foreach ($rows as $row) { |
| 672 |
|
$sql = "UPDATE $this->_tbl SET ordering=$i WHERE $k = ".$row->$k; |
| 673 |
|
$database->doSQL($sql); |
| 674 |
|
$i++; |
| 675 |
|
} |
| 676 |
|
return true; |
| 677 |
|
} |
| 678 |
|
|
| 679 |
|
} |
| 680 |
|
|
| 681 |
|
|
| 682 |
|
/** |
| 683 |
|
* mosDBTable Abstract Class. |
| 684 |
|
* @abstract |
| 685 |
|
* @package Mambo |
| 686 |
|
* @subpackage Database |
| 687 |
|
* |
| 688 |
|
* Parent classes to all database derived objects. Customisation will generally |
| 689 |
|
* not involve tampering with this object. |
| 690 |
|
* @package Mambo |
| 691 |
|
* @author Andrew Eddie <eddieajau@users.sourceforge.net |
| 692 |
|
*/ |
| 693 |
|
class mosDBTable extends mosDBAbstractRow { |
| 694 |
|
/** @var mosDatabase Database connector */ |
| 695 |
|
var $_db = null; |
| 696 |
|
|
| 697 |
/** |
/** |
| 698 |
* @return bool True if DB query failed. Sets the error message |
* @return bool True if DB query failed. Sets the error message |
| 709 |
*/ |
*/ |
| 710 |
function filter( $ignoreList=null ) { |
function filter( $ignoreList=null ) { |
| 711 |
$callcheck = array('InputFilter', 'process'); |
$callcheck = array('InputFilter', 'process'); |
| 712 |
if (!is_callable($callcheck)) require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpinputfilter/class.inputfilter.php'); |
if (!is_callable($callcheck)) require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpInputFilter/class.inputfilter.php'); |
| 713 |
// specific filters |
// specific filters |
| 714 |
$iFilter =& new InputFilter(); |
$iFilter =& new InputFilter(); |
| 715 |
if (is_array($ignoreList)) foreach ($this->getPublicProperties() as $k) { |
if (is_array($ignoreList)) foreach ($this->getPublicProperties() as $k) { |
| 749 |
return $cache; |
return $cache; |
| 750 |
} |
} |
| 751 |
/** |
/** |
|
* Checks if this object lacks the property given by the parameter |
|
|
* @param string The name of the property |
|
|
* @return bool |
|
|
*/ |
|
|
function lacks( $property ) { |
|
|
$thisclass = strtolower(get_class($this)); |
|
|
if (!array_key_exists( $property, get_class_vars($thisclass) )) { |
|
|
$this->_error = "WARNING: $thisclass does not support $property."; |
|
|
return true; |
|
|
} |
|
|
return false; |
|
|
} |
|
|
/** |
|
| 752 |
* Set the value of the class variable |
* Set the value of the class variable |
| 753 |
* @param string The name of the class variable |
* @param string The name of the class variable |
| 754 |
* @param mixed The value to assign to the variable |
* @param mixed The value to assign to the variable |
| 764 |
* @return null|string null is operation was satisfactory, otherwise returns an error |
* @return null|string null is operation was satisfactory, otherwise returns an error |
| 765 |
*/ |
*/ |
| 766 |
function bind( $array, $ignore="" ) { |
function bind( $array, $ignore="" ) { |
| 767 |
$database = mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 768 |
if (is_array($array)) return $database->mosBindArrayToObject($array, $this, $ignore); |
if (is_array($array)) return $database->mosBindArrayToObject($array, $this, $ignore); |
| 769 |
$this->_error = strtolower(get_class( $this ))."::bind failed."; |
$this->_error = strtolower(get_class( $this ))."::bind failed."; |
| 770 |
return false; |
return false; |
| 784 |
} |
} |
| 785 |
|
|
| 786 |
/** |
/** |
|
* generic check method |
|
|
* |
|
|
* can be overloaded/supplemented by the child class |
|
|
* @return boolean True if the object is ok |
|
|
*/ |
|
|
function check() { |
|
|
return true; |
|
|
} |
|
|
|
|
|
/** |
|
| 787 |
* Inserts a new row if id is zero or updates an existing row in the database table |
* Inserts a new row if id is zero or updates an existing row in the database table |
| 788 |
* |
* |
| 789 |
* Can be overloaded/supplemented by the child class |
* Can be overloaded/supplemented by the child class |
| 802 |
} |
} |
| 803 |
|
|
| 804 |
/** |
/** |
|
* Determine from the direction parameter which operator and order to use in SQL |
|
|
*/ |
|
|
function orderCodes ($direction) { |
|
|
if ($direction < 0) { |
|
|
$relation = '<'; |
|
|
$ordering = ' ORDER BY ordering DESC'; |
|
|
} |
|
|
elseif ($direction > 0) { |
|
|
$relation = '>'; |
|
|
$ordering = ' ORDER BY ordering ASC'; |
|
|
} |
|
|
else { |
|
|
$relation = '='; |
|
|
$ordering = ''; |
|
|
} |
|
|
return array ($relation, $ordering); |
|
|
} |
|
|
/** |
|
|
*/ |
|
|
function move( $direction, $where='' ) { |
|
|
$k = $this->_tbl_key; |
|
|
list ($relation, $ordering) = $this->orderCodes($direction); |
|
|
$sql = "SELECT $this->_tbl_key, ordering FROM $this->_tbl WHERE ordering $relation $this->ordering"; |
|
|
$sql .= ($where ? "\n AND $where" : '').$ordering.' LIMIT 1'; |
|
|
$this->_db->setQuery( $sql ); |
|
|
$row = null; |
|
|
if ($this->_db->loadObject($row)) { |
|
|
$sql = "UPDATE $this->_tbl SET ordering='$row->ordering' WHERE $this->_tbl_key='".$this->$k."'"; |
|
|
$this->_db->doSQL($sql); |
|
|
} |
|
|
$sql = "UPDATE $this->_tbl SET ordering='$this->ordering' WHERE $this->_tbl_key='".$row->$k."'"; |
|
|
if ($row) $this->ordering = $row->ordering; |
|
|
$this->_db->doSQL($sql); |
|
|
} |
|
|
/** |
|
|
* Compacts the ordering sequence of the selected records |
|
|
* @param string Additional where query to limit ordering to a particular subset of records |
|
|
*/ |
|
|
function updateOrder( $where='' ) { |
|
|
if ($this->lacks('ordering')) return false; |
|
|
$k = $this->_tbl_key; |
|
|
if ($this->_tbl == "#__content_frontpage") $order2 = ", content_id DESC"; |
|
|
else $order2 = ""; |
|
|
|
|
|
$sql = "SELECT $k, ordering FROM $this->_tbl " |
|
|
. ($where ? "\nWHERE $where" : '') |
|
|
. "\nORDER BY ordering$order2"; |
|
|
$this->_db->setQuery($sql); |
|
|
if (!$rows = $this->_db->loadObjectList()) { |
|
|
$this->_error = $this->_db->getErrorMsg(); |
|
|
return false; |
|
|
} |
|
|
$neworder = max(min($this->ordering, count($rows)), 1); |
|
|
$i = 1; |
|
|
foreach ($rows as $row) { |
|
|
$key = $row->$k; |
|
|
if ($i == $neworder) $i++; |
|
|
if ($key == $this->$k) { |
|
|
$i--; |
|
|
$ordering = $neworder; |
|
|
} |
|
|
else $ordering = $i; |
|
|
$sql = "UPDATE $this->_tbl SET ordering=$ordering WHERE $k = $key "; |
|
|
$this->_db->doSQL($sql); |
|
|
$i++; |
|
|
} |
|
|
return true; |
|
|
} |
|
|
|
|
|
/** |
|
| 805 |
* Default delete method |
* Default delete method |
| 806 |
* |
* |
| 807 |
* can be overloaded/supplemented by the child class |
* can be overloaded/supplemented by the child class |
| 937 |
* of a field that will have a timestamp placed in it whenever the DB is written. |
* of a field that will have a timestamp placed in it whenever the DB is written. |
| 938 |
*/ |
*/ |
| 939 |
|
|
| 940 |
class mosDBTableEntry { |
class mosTableEntry extends mosDBAbstractRow { |
|
/** @var int ID for file record in database */ |
|
|
var $id = 0; |
|
|
var $database = ''; |
|
|
|
|
|
function mosDBTableEntry () { |
|
|
die ('Cannot instantiate mosDBTableEntry'); |
|
|
} |
|
|
|
|
|
function getDatabase () { |
|
|
if (!is_object($this->database)) $this->database = mamboDatabase::getInstance(); |
|
|
return $this->database; |
|
|
} |
|
| 941 |
|
|
| 942 |
/* Stores all POST data where the name matches an object variable name */ |
/* Stores all POST data where the name matches an object variable name */ |
| 943 |
function addPostData () { |
function addPostData () { |
| 944 |
foreach (get_class_vars(get_class($this)) as $field=>$value) { |
foreach (get_class_vars(get_class($this)) as $field=>$value) { |
| 945 |
if ($field!='id' AND isset($_POST[$field])) { |
if ($field!='id' AND $field[1] != '_' AND isset($_POST[$field])) { |
| 946 |
$this->$field = trim($_POST[$field]); |
$this->$field = trim($_POST[$field]); |
| 947 |
} |
} |
| 948 |
} |
} |
| 958 |
/* Updates an existing DB entry with the object's current values */ |
/* Updates an existing DB entry with the object's current values */ |
| 959 |
function updateObjectDB () { |
function updateObjectDB () { |
| 960 |
$this->prepareValues(); |
$this->prepareValues(); |
| 961 |
$database = $this->getDatabase(); |
$database = mamboDatabase::getInstance(); |
| 962 |
$database->doSQL($this->updateSQL()); |
$database->doSQL($this->updateSQL()); |
| 963 |
} |
} |
| 964 |
|
|
| 966 |
function delete () { |
function delete () { |
| 967 |
$table = $this->tableName(); |
$table = $this->tableName(); |
| 968 |
$sql = "DELETE FROM $table WHERE id=$this->id"; |
$sql = "DELETE FROM $table WHERE id=$this->id"; |
| 969 |
$database = $this->getDatabase(); |
$database = mamboDatabase::getInstance(); |
| 970 |
$database->doSQL($sql); |
$database->doSQL($sql); |
| 971 |
} |
} |
| 972 |
|
|
| 981 |
$sql = "UPDATE $tabname SET %s WHERE id=$this->id"; |
$sql = "UPDATE $tabname SET %s WHERE id=$this->id"; |
| 982 |
$exclude = $this->notSQL(); |
$exclude = $this->notSQL(); |
| 983 |
foreach (get_class_vars(get_class($this)) as $field=>$value) { |
foreach (get_class_vars(get_class($this)) as $field=>$value) { |
| 984 |
if (!in_array($field,$exclude)) $setter[] = $field."='".$this->$field."'"; |
if (!in_array($field,$exclude) AND $field[0] != '_') $setter[] = $field."='".$this->$field."'"; |
| 985 |
} |
} |
| 986 |
$timestamp = $this->timeStampField(); |
$timestamp = $this->timeStampField(); |
| 987 |
if ($timestamp) $setter[] = $timestamp."='".date('Y-m-d H:i:s')."'"; |
if ($timestamp) $setter[] = $timestamp."='".date('Y-m-d H:i:s')."'"; |
| 1000 |
$sql = "INSERT INTO $tabname (%s) VALUES (%s)"; |
$sql = "INSERT INTO $tabname (%s) VALUES (%s)"; |
| 1001 |
$exclude = $this->notSQL(); |
$exclude = $this->notSQL(); |
| 1002 |
foreach (get_class_vars(get_class($this)) as $field=>$value) { |
foreach (get_class_vars(get_class($this)) as $field=>$value) { |
| 1003 |
if (!in_array($field,$exclude)) { |
if (!in_array($field,$exclude) AND $field[0] != '_') { |
| 1004 |
$infields[] = $field; |
$infields[] = $field; |
| 1005 |
$values[] = "'".$this->$field."'"; |
$values[] = "'".$this->$field."'"; |
| 1006 |
} |
} |
| 1022 |
|
|
| 1023 |
/* Ensures values can safely be written to DB; assumes magic quotes forced off */ |
/* Ensures values can safely be written to DB; assumes magic quotes forced off */ |
| 1024 |
function prepareValues () { |
function prepareValues () { |
| 1025 |
$database = $this->getDatabase(); |
$database = mamboDatabase::getInstance(); |
| 1026 |
foreach (get_class_vars(get_class($this)) as $field=>$value) { |
foreach (get_class_vars(get_class($this)) as $field=>$value) { |
| 1027 |
if (!is_numeric($this->$field)) $this->$field = $database->getEscaped($this->$field); |
if (!is_numeric($this->$field) AND is_string($this->$field)) $this->$field = $database->getEscaped($this->$field); |
| 1028 |
} |
} |
| 1029 |
} |
} |
| 1030 |
|
|
| 1031 |
/* Takes some arbitrary SELECT type SQL and places the first or only result into the current object */ |
/* Takes some arbitrary SELECT type SQL and places the first or only result into the current object */ |
| 1032 |
function readDataBase($sql) { |
function readDataBase($sql) { |
| 1033 |
$database = $this->getDatabase(); |
$database = mamboDatabase::getInstance(); |
| 1034 |
$database->setQuery( $sql ); |
$database->setQuery( $sql ); |
| 1035 |
if (!$database->loadObject($this)) $this->id = 0; |
if (!$database->loadObject($this)) $this->id = 0; |
| 1036 |
} |
} |