File: //home/bk/efi/eficenter.ru/modules/article/lib/class.articleDB.php
<?php
class CArticleData_DB extends TObject {
var $id = NULL;
var $title = NULL;
var $text = NULL;
var $active = NULL;
function CArticleData_DB ($table, $PK) {
$this->TObject($table, $PK);
}
function load ($id) {
global $CONFIG, $admin;
if ($admin) $active = "AND active = 1";
else $active = "";
$sql = "SELECT * FROM $this->_tbl WHERE $this->_tbl_key = '$id' $active";
return db_loadObject($sql, $this);
}
function list_by_type($type, $order_by, $start_row, $rows, $search) {
if ($type == "active") {
$sql = "SELECT * FROM $this->_tbl WHERE active = 1 ORDER BY $order_by";
} else if ($type == "pages") {
$sql = "SELECT * FROM $this->_tbl ORDER BY $order_by LIMIT $start_row,$rows";
} else if ($type == "search") {
$sql = "SELECT * FROM $this->_tbl WHERE title LIKE '%$search%' OR text LIKE '%$search%' OR id = '$search' GROUP BY id ORDER BY $order_by";
} else {
$sql = "SELECT * FROM $this->_tbl ORDER BY $order_by";
}
return db_loadList($sql);
}
}
?>