本文整理汇总了PHP中DB_DataObject类的典型用法代码示例。如果您正苦于以下问题:PHP DB_DataObject类的具体用法?PHP DB_DataObject怎么用?PHP DB_DataObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DB_DataObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($cmid = 0)
{
global $db;
$this->_cmid = $cmid;
if ($this->_cmid != 0) {
$this->_dbo = DB_DataObject::Factory("phph_comments");
if (PEAR::isError($this->_dbo)) {
throw new Exception2("Bd wewn�rzny", $this->_dbo->getMessage());
}
$r = $this->_dbo->get($cmid);
if (PEAR::isError($r)) {
throw new Exception2("Bd wewn�rzny", $r->getMessage());
}
if ($r == 0) {
throw new Exception2("Bd", "Komentarz nie istnieje", COMMENT_NOT_FOUND);
}
$this->_user = DB_DataObject::Factory("phph_users");
if (PEAR::isError($this->_user)) {
throw new Exception2("Bd wewn�rzny", $this->_user->getMessage());
}
$r = $this->_user->get($this->_dbo->user_id);
if (PEAR::isError($r)) {
throw new Exception2("Bd wewn�rzny", $r->getMessage());
}
if ($r == 0) {
throw new Exception2("Bd sp�noci danych", "Uytkownik do kt�ego nalezy komentarz nie istnieje.<br />Skontakuj si�z administratorem, podajc numer komentarza ({$cmid}).", COMMENT_USER_NOT_FOUND);
}
}
}
示例2: _newImage
protected function _newImage(DB_DataObject $obj)
{
$defs = $obj->_getPluginsDef();
$tbl = DB_DataObject::factory($defs['otfimagereceiver']['table']);
$tbl->record_table = $obj->tableName();
$tbl->record_id = $obj->pk();
return $tbl;
}
示例3: __construct
public function __construct(DB_DataObject $do, $values)
{
$this->do = $do;
if (!is_array($values)) {
throw new Exception('Values must be an array !');
}
$this->values = $values;
$this->db = $do->getDatabaseConnection();
}
示例4: getSessionFilterSubTable
/**
* @param DB_DataObject $class
* @param string $label
* @param string $field
* @return array
*/
function getSessionFilterSubTable($class, $label, $field)
{
$class->orderBy('value ASC');
$class->find();
$filter = array();
$filter['label'] = $label;
$filter['field'] = $field;
$filter['values'] = array();
$filter['values']['null'] = 'unset';
while ($class->fetch()) {
$filter['values'][$class->id] = $class->value;
}
natcasesort($filter['values']);
return $filter;
}
示例5: del
function del($params)
{
$json = new Services_JSON();
$subcategory = DB_DataObject::factory("subcategory");
$subcategory->id = $params["id"];
print $subcategory->delete() ? $json->encode(array("error" => false)) : $json->encode(array("error" => true));
}
示例6: getq
function getq($params)
{
$json = new Services_JSON();
$item = DB_DataObject::factory("item");
if (isset($params["categ"]) && $params["categ"] > 0) {
$item->whereAdd("subcategory_id = {$params['categ']}", "OR");
$item->whereAdd("subcategory_id2 = {$params['categ']}", "OR");
$item->whereAdd("subcategory_id3 = {$params['categ']}", "OR");
}
$count = $item->count();
$total = $count > 0 ? ceil($count / (int) $params["rows"]) : 0;
$page = min($params["page"], $total);
$start = max(0, (int) $params["rows"] * $page - (int) $params["rows"]);
$item->selectAdd();
$item->selectAdd("id, url, title, descr");
$item->orderBy("{$params['sidx']} {$params['sord']}");
$item->limit($start, (int) $params["rows"]);
$item->find();
$res = array();
while ($item->fetch()) {
$res["rows"][] = array("id" => $item->id, "cell" => array($item->id, $item->url, $item->title, $item->descr));
}
$res["page"] = $page;
$res["total"] = $total;
$res["records"] = $count;
print $json->encode($res);
}
示例7: init
function init($pg)
{
$group = DB_DataObject::factory('core_group');
// group should be auto created - by update-database...
if (!$group->get('name', 'core-person-signup-bcc')) {
$group = DB_DataObject::factory('core_group');
$group->name = 'core-person-signup-bcc';
$group->insert();
}
$p = DB_DataObject::factory('core_person');
if (!$p->count()) {
return;
// can not check people...
}
// got people...
$member = DB_DataObject::factory('core_group_member');
$member->group_id = $group->id;
if ($member->count()) {
return;
}
// not got members..
// if we only have one member - then add it .... (it's the admin, and they can modify this later.. - after they get annoyed with it..
$p->find(true);
$member = DB_DataObject::factory('core_group_member');
$member->group_id = $group->id;
$member->user_id = $p->id;
$member->insert();
// only display if we have members..
}
示例8: launchFacebook
function launchFacebook($terminoBuscar)
{
$app_access_token = genToken();
$resultFacebook = app_request("https://graph.facebook.com/v2.5/search?q=" . $terminoBuscar . "&type=page&limit=10&fields=id,name,picture.type(normal),likes&" . $app_access_token);
//printVar($resultFacebook,$_SERVER['SERVER_NAME'].'/publication/search/results/resultFacebook.json');
//printVar($_SERVER["DOCUMENT_ROOT"]);
$fp = fopen($_SERVER["DOCUMENT_ROOT"] . '/publication/search/results/resultFacebook.json', 'w');
$qpaso = fwrite($fp, json_encode($resultFacebook));
fclose($fp);
//printVar($qpaso,'que paso');
$obj = DB_DataObject::Factory('MpBrand');
$obj->name = $terminoBuscar;
$find = $obj->find();
if ($find > 0) {
// echo 'entra al if';
while ($obj->fetch()) {
//DB_DataObject::debugLevel(1);
$obj->picture = $resultFacebook['data'][0]['picture']['data']['url'];
$obj->update();
}
} else {
}
$obj->free();
//echo json_encode('');
}
示例9: execute
function execute(&$controller, &$request, &$user)
{
$account = $request->getParameter('account');
$format = $request->hasParameter('format') ? $request->getParameter('format') : 'html';
$member = DB_DataObject::factory('member');
$member->get('account', $account);
$site = DB_DataObject::factory('site');
$site->get('member_id', $member->id);
$feed = DB_DataObject::factory('feed');
$feeds = $feed->getListsByAccount($account);
switch ($format) {
case 'opml11':
foreach ($feeds as $key => $feed) {
$f = array('title' => $feed->title, 'text' => $feed->description, 'link' => $feed->link, 'uri' => $feed->uri);
$feeds[$key] = $f;
}
$writer =& new OPMLWriter();
$writer->setHead(array('title' => $site->title, 'date' => time(), 'owner' => $account));
$writer->setOutlines($feeds);
$writer->display($format);
return VIEW_NONE;
case 'html':
default:
$request->setAttribute('sources', $feeds);
return VIEW_SUCCESS;
}
}
示例10: recover
function recover($code)
{
if (!$this->getAuthUser()) {
$this->jerr("invalid");
}
// fixme!!!!
$fn = $this->rootDir . '/Pman/' . $code . '.js';
list($app, $mod) = explode('/', $code);
if (!file_exists($fn)) {
$this->jerr("file does not exist.:" . $fn);
}
$data = file_get_contents($fn);
preg_match("#/*\n--SOURCE--\n([^\\*]+)#m", $data, $matches);
// echo "<PRE>";print_R($matches);
$base = $matches[1];
$str = bzdecompress(base64_decode($base));
$js = json_decode($str);
//echo "<PRE>";print_R($str);
$b = DB_DataObject::factory('builder');
$b->app = $app;
$b->module = $mod;
$b->btype = 'FORM';
$b->name = $js->name;
if (!$b->find(true)) {
$b->insert();
}
echo "<PRE>" . htmlspecialchars(print_r($b, true));
$b->json = $str;
$b->update();
$this->jok("DONE");
exit;
}
示例11: login
function login()
{
$this->showStylesheets();
$nickname = common_canonical_nickname($this->trimmed('nickname'));
$password = $this->arg('password');
$msg = null;
if ($nickname) {
if (common_check_user($nickname, $password)) {
$user = User::staticGet('nickname', $nickname);
if (!$user) {
$this->showLoginForm(_m("Server error: Couldn't get user!"));
}
$flink = DB_DataObject::factory('foreign_link');
$flink->user_id = $user->id;
$flink->foreign_id = $this->fbuid;
$flink->service = FACEBOOK_SERVICE;
$flink->created = common_sql_now();
$flink->set_flags(true, false, false, false);
$flink_id = $flink->insert();
// XXX: Do some error handling here
$this->setDefaults();
$this->getUpdatePermission();
return;
} else {
$msg = _m('Incorrect username or password.');
}
}
$this->showLoginForm($msg);
$this->showFooter();
}
示例12: listGroupMembership
/**
* Get a list of memberships for a person
* @param Pman_Core_DataObjects_Person $person who
* @param String column to fetch.. eg. group_id or 'name'
*
*/
function listGroupMembership($person, $arrayof = 'group_id')
{
$this->inAdmin = false;
$t = clone $this;
//DB_DataObject::debugLevel(1);
$grp = DB_DataObject::factory('core_group');
$t->joinAdd($grp, 'LEFT');
//$person->id = (int)$person->id;
$t->whereAdd("\n user_id = {$person->id}\n ");
$t->selectAdd();
$t->selectAdd("distinct(group_id), {$grp->tableName()}.name as name");
$t->whereAdd('group_id IS NOT NULL');
$t->find();
$ret = array();
// $ret = $arrayof == 'group_id' ? array(0) : array();
// default member of 'All groups'!!
while ($t->fetch()) {
$ret[] = $t->{$arrayof};
if ($t->name == 'Administrators') {
/// mmh... bit risky?
$this->inAdmin = true;
}
}
if ($arrayof == 'group_id' && !count($ret)) {
$ret = array(0);
/// default if they are not a member of any group.
}
//var_dump($ret);
return $ret;
}
示例13: lunchReport
public function lunchReport($idBrand, $idSocialNetwork, $idInteraction)
{
$report = DB_DataObject::Factory('MpBrandXSocialNetwork');
// DB_DataObject::debugLevel(1);
$report->idBrand = $idBrand;
$report->idInteraction = $idInteraction;
$report->idSocialNetwork = $idSocialNetwork;
$find = $report->find();
if ($find > 0) {
while ($report->fetch()) {
if ($report->status == 'L') {
$report->status = 'E';
$report->update();
}
}
} else {
$report->snID = "Aqui va algo";
$report->ownedBrand = 'N';
$report->status = 'E';
$report->date = date('Y-m-d h:i:s');
$l = $report->insert();
// printVar($l);
}
$report->free();
return 'ok';
}
示例14: get
function get($table)
{
$d = DB_DAtaObject::Factory($table);
if (method_exists($d, 'availableColumns')) {
$cols = $d->availableColumns();
} else {
$re = $d->autoJoin();
//echo '<PRE>';print_r($re);
$cols = $re['cols'];
$types = array();
$tables = array();
$schemas = array($table => $d->table());
foreach ($cols as $name => $table_col) {
list($tbl, $col) = explode('.', $table_col);
if (!isset($schemas[$tbl])) {
$schemas[$tbl] = DB_DataObject::Factory($tbl)->table();
}
$types[$name] = $schemas[$tbl][$col];
$tables[$name] = $tbl;
}
foreach ($re['join_names'] as $c => $f) {
$cols[$c] = $f;
}
}
foreach ($cols as $c => $f) {
$ret[] = array('name' => $c, 'val' => $f, 'type' => isset($types[$c]) ? $this->typeToName($types[$c]) : -1, 'table' => isset($tables[$c]) ? $tables[$c] : "");
}
$this->jdata($ret);
}
示例15: post
function post()
{
$si = DB_DataObject::factory('Signup');
if (empty($_REQUEST['id']) || !$si->get($_REQUEST['id'])) {
$this->jerr("invalid request");
}
if ($si->person_id != 0) {
$si->jerr("Account already processed");
}
// rejected..
if ($_REQUEST['person_id'] < 0) {
$si->setFrom($_REQUEST);
$si->update();
$this->jok("OK");
}
$p = DB_DataObject::factory("core_person");
$p->setFrom($_REQUEST);
$p->insert();
$si->setFrom($_REQUEST);
$si->person_id = $p->id;
$si->update();
// generate a password
// and send welcome message.
$this->jok($p->toArray());
}