本文整理汇总了PHP中DB_DataObject::Factory方法的典型用法代码示例。如果您正苦于以下问题:PHP DB_DataObject::Factory方法的具体用法?PHP DB_DataObject::Factory怎么用?PHP DB_DataObject::Factory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_DataObject
的用法示例。
在下文中一共展示了DB_DataObject::Factory方法的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: 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';
}
示例3: 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);
}
示例4: 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('');
}
示例5: get
function get()
{
$this->transObj = DB_DataObject::Factory('core_enum');
$this->transObj->query('BEGIN');
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
$this->modules = $this->modulesList();
$this->etype();
$this->defaults();
foreach ($this->defaults as $k => $v) {
$enum = DB_DataObject::factory('core_enum');
$enum->setFrom(array('etype' => $this->etype->name, 'name' => $k, 'active' => 1));
if ($enum->find(true)) {
continue;
}
$enum->display_name = $v;
$enum->insert();
}
$notify = DB_DataObject::factory('core_notify');
$notify->selectAdd();
$notify->selectAdd("\n DISTINCT(evtype) AS evtype\n ");
$types = $notify->fetchAll();
foreach ($types as $t) {
$enum = DB_DataObject::factory('core_enum');
$enum->setFrom(array('etype' => $this->etype->name, 'name' => $t->evtype, 'active' => 1));
if ($enum->find(true)) {
continue;
}
$enum->display_name = $t->evtype;
$enum->insert();
}
$this->jok('DONE');
}
示例6: getUserLevel
static function getUserLevel($uid)
{
global $db;
$gl = 0;
$q = $db->prepare("SELECT IFNULL(MAX(group_level), 0) AS gl FROM phph_groups WHERE group_id IN (SELECT group_id FROM phph_group_users WHERE user_id = ?)");
if (PEAR::isError($q)) {
die($q->getMessage());
}
$r = $db->execute($q, $uid);
if (PEAR::isError($r)) {
die($r->getMessage());
}
$row = $r->fetchRow();
$gl = $row['gl'];
$user = DB_DataObject::Factory("phph_users");
if (PEAR::isError($user)) {
die($user->getMessage());
}
$r = $user->get($uid);
if (PEAR::isError($r)) {
die($r->getMessage());
}
if ($r == 0) {
return 0;
}
return max($gl, $user->user_level);
}
示例7: get
function get($id)
{
$ev = DB_DataObject::Factory('Events');
if (!$ev->get((int) $id)) {
$this->jerr("invalid id");
}
// verify if not admin, then they should
$g = DB_DataObject::Factory('core_group_member');
if (is_a($g, 'DB_DataObject')) {
$grps = $g->listGroupMembership($this->authUser);
//var_dump($grps);
$isAdmin = $g->inAdmin;
if (!$isAdmin && $ev->person_id != $this->authUser->id) {
$this->jerrAuth();
}
}
echo '<PRE>' . htmlspecialchars(print_r($ev->toArray(), true)) . "</PRE>";
// we have 2 bits of data available at present:
// core_event_audit
// the event file..
$d = DB_DataObject::factory('core_event_audit');
if (is_a($d, 'DB_DataObject')) {
echo "<H2>Changed Data:</H2>";
$d->event_id = $ev->id;
foreach ($d->fetchAll() as $d) {
echo "{$d->name} SET TO: " . htmlspecialchars($d->newvalue) . "<br/>\n";
}
}
echo "<HR><H2>Posted Data:</H2>";
$logdir = DB_DAtaObject::Factory('Events')->logDir();
if (!$logdir) {
echo "not available (Pman[storedir] not configured)";
exit;
}
$file = $logdir . date('/Y/m/d/', strtotime($ev->event_when)) . $ev->id . ".php";
if (file_exists($file)) {
echo '<PRE>' . htmlspecialchars(file_get_contents($file)) . '</PRE>';
}
$file = $logdir . date('/Y/m/d/', strtotime($ev->event_when)) . $ev->id . ".json";
if (!file_exists($file)) {
echo "not available (missing file) {$file}";
exit;
}
echo '<PRE>' . htmlspecialchars(print_r(json_decode(file_get_contents($file)), true)) . '</PRE>';
echo '<BR/><PRE>' . htmlspecialchars($ev->remarks) . '</PRE>';
$json = json_decode($ev->remarks, JSON_PRETTY_PRINT);
if (json_last_error() == JSON_ERROR_NONE) {
echo "<HR><H2>JSON DECODE Data:</H2>";
echo '<PRE>' . print_r($json, true) . '</PRE>';
}
$filesJ = json_decode(file_get_contents($file));
echo '<br /><PRE>Download files</PRE>';
foreach ($filesJ->FILES as $k => $f) {
$ip = $ff->baseURL . "/Images/events/" . $ev->id . '/' . $f->tmp_name;
echo '<a href="' . $ip . '/download">' . htmlspecialchars($k . ' - ' . $f->name) . '</a><br/>';
}
exit;
}
示例8: get
function get($args, $opts)
{
//DB_DataObject::DebugLevel(1);
$d = DB_DataObject::Factory('core_curr_rate');
$d->loadRates();
$hkd = $d->convert(1, 'USD', 'HKD');
echo "1 USD is ~ {$hkd} HKD (should be about 7.75)\n ";
die("done");
}
示例9: post
function post()
{
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
$this->sessionState(0);
// turn off the session..
$img = DB_DataObject::Factory('images');
$img->setFrom(array('onid' => 0, 'ontable' => 'ipshead'));
$img->onUpload(false);
require_once 'File/Convert.php';
$fc = new File_Convert($img->getStoreName(), $img->mimetype);
$csv = $fc->convert('text/csv');
$this->importCsv($csv);
}
示例10: post
function post()
{
$this->transObj = DB_DataObject::Factory('invhist_transfer');
$this->transObj->query('BEGIN');
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
$img = DB_DataObject::Factory('images');
$img->setFrom(array('onid' => 0, 'ontable' => 'ipshead'));
$img->onUpload(false);
require_once 'File/Convert.php';
$fc = new File_Convert($img->getStoreName(), $img->mimetype);
$csv = $fc->convert('text/csv');
$ret = $this->importCsv($csv);
$this->jdata($ret['data'], false, isset($ret['extra']) ? $ret['extra'] : array());
}
示例11: get
function get($app)
{
die("DISABLED");
$b = DB_DataObject::Factory('Builder');
$b->find();
echo '<PRE>';
$dir = "/home/gitlive/";
$map = array('Clipping' => 'web.MediaOutreach/Pman/Clipping', 'PressRelease' => 'web.MediaOutreach/Pman/PressRelease', 'Ris' => 'web.Ris/Pman/Ris', 'TestApp' => false, 'Hex' => false, 'Example' => false, 'ExampleOld' => false, 'Deleted' => false, 'DealFlow' => 'web.Dealflow/Pman/DealFlow', 'Aviation' => 'web.Aviation/Pman/Aviation');
$dirs = array();
while ($b->fetch()) {
// print_r($b);
$data = json_decode($b->json);
$data->title = $data->name;
$data->name = $data->{'|module'};
if (empty($data->name)) {
continue;
}
// {"id":"roo-file-1","name":"layout test.bjs","parent":"","title":false,"path":"/h
//ome/alan/buildertest/layout test.bjs"
$fn = $dir . "Pman." . trim($data->app) . '/' . $data->name . '.bjs';
if (isset($map[trim($data->app)])) {
if ($map[trim($data->app)] === false) {
continue;
}
$fn = $dir . $map[$data->app] . '/' . $data->name . '.bjs';
}
if (!file_exists(dirname($fn))) {
print "<B>SKIP " . $fn . "</B>\n";
continue;
}
$dirs[dirname($fn)] = true;
echo "WRITE : " . $fn . "\n";
//echo " " .htmlspecialchars(json_encode($data)) . "\n";
file_put_contents($fn, json_encode($data));
}
print_r($dirs);
foreach ($dirs as $d => $n) {
chdir($d);
$cmd = 'git pull 2>&1';
echo $cmd . "\n" . `{$cmd}`;
$cmd = 'git add --all 2>&1';
echo $cmd . "\n" . `{$cmd}`;
$cmd = "git commit -m 'add bjs' -a --author='Alan Knowles <alan@akbkhome.com>' 2>&1";
echo $cmd . "\n" . `{$cmd}`;
$cmd = "git push 2>&1";
echo $cmd . "\n" . `{$cmd}`;
}
exit;
}
示例12: getall
public function getall()
{
global $g;
$data_obj = \DB_DataObject::Factory('mycms\\' . $this->m_type);
if ($data_obj instanceof \DB_DataObject_Error) {
$g['error']->push($data_obj->message);
return;
}
$count = $data_obj->find();
$rows = array();
while ($data_obj->fetch()) {
$rows[] = clone $data_obj;
}
return array('rows' => $rows, 'count' => $count);
}
示例13: makeCopy
function makeCopy($roo)
{
$c = DB_DataObject::Factory($this->tableName());
$c->setFrom($this);
$c->name = "COPY of " . $this->name;
$c->updated_dt = $this->sqlValue('NOW()');
$id = $c->insert();
$c = DB_DataObject::Factory($this->tableName());
$c->get($id);
// copy images.
$i = DB_DataObject::factory('Images');
$i->onid = $this->id;
$i->ontable = $this->tableName();
$i->find();
while ($i->fetch()) {
$new_image = DB_DataObject::factory('Images');
$new_image->onid = $c->id;
$new_image->ontable = $this->tableName();
$new_image->createFrom($i->getStoreName(), $i->filename);
$map[$i->id] = $new_image->id;
}
libxml_use_internal_errors(true);
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->loadHTML('<?xml encoding="UTF-8"><HTML><BODY>' . $this->bodytext . '</BODY></HTML>');
$doc->formatOutput = true;
//echo '<PRE>'; print_R($doc);
$xpath = new DOMXpath($doc);
foreach ($xpath->query('//img[@src]') as $img) {
$href = $img->getAttribute('src');
//var_dump($href);
$matches = array();
if (preg_match("/Images\\/([0-9]+)\\/([^#]+)\\#image\\-([0-9]+)\$/", $href, $matches)) {
$oid = $matches[1];
if (!isset($map[$oid])) {
//echo "skip no new id for $oid";
continue;
}
$nid = $map[$oid];
$nstr = "/Images/{$nid}/{$matches[2]}/#image-{$nid}";
$img->setAttribute('src', str_replace($matches[0], $nstr, $href));
}
}
$cc = clone $c;
$c->bodytext = $doc->saveHTML();
$c->update($cc);
libxml_use_internal_errors(false);
$roo->jok("duplicated");
}
示例14: insertAnalytics
public function insertAnalytics($pagina, $usuario, $pass, $idBrand)
{
$web = DB_DataObject::Factory('MpWeb');
// DB_DataObject::debugLevel(1);
$web->url = $pagina;
$web->idBrand = $idBrand;
$find = $web->find();
if ($find > 0) {
while ($web->fetch()) {
$web->analyticsUser = $usuario;
$web->analyticsPass = $pass;
$web->update();
}
}
$web->free();
}
示例15: get
function get()
{
// must recieve a group..
if (!isset($_GET['group_id']) || (int) $_GET['group_id'] < 0) {
$this->jerr("NO GROUP");
}
if (!$this->hasPerm('Core.Groups', 'S')) {
// listing groups..
$this->jerr("PERMISSION DENIED");
}
$g = DB_DataObject::Factory('core_group');
if (!$g->get($_GET['group_id'])) {
$this->jerr("group is invalid");
}
//print_r($g);
// DB_DataObject::debugLevel(1);
$p = DB_DataObject::factory('core_group_right');
$p->group_id = (int) $_GET['group_id'];
$p->find();
$cur = array();
while ($p->fetch()) {
$cur[$p->rightname] = clone $p;
}
$e = -1;
$ar = array();
// echo "<PRE>"; print_r($p->defaultPermData() );
foreach ($p->defaultPermData() as $k => $defdata) {
if (empty($defdata[0])) {
// no admin data available..
continue;
}
if (!isset($cur[$k])) {
// then there is no current access right for it..
//DB_DataObject::debugLevel(1);
$gr = DB_DataObject::factory('core_group_right');
$gr->group_id = (int) $_GET['group_id'];
$gr->rightname = $k;
$gr->accessmask = $g->type == 2 ? '' : $defdata[1];
// set to defaults.. unless it's a contact group.
$gr->insert();
$cur[$k] = clone $gr;
}
$ar[] = array('id' => $cur[$k]->id * 1, 'rightname' => $k, 'descript' => isset($defdata[2]) ? $defdata[2] : '', 'accessmask' => $cur[$k]->accessmask, 'FullMask' => $defdata[0], 'group_id' => (int) $_GET['group_id']);
}
$this->jdata($ar);
}