protected function importAdditionalData($b, $blockNode) { if (isset($blockNode->data)) { foreach ($blockNode->data as $data) { if ($data['table'] != $this->getBlockTypeDatabaseTable()) { $table = (string) $data['table']; if (isset($data->record)) { foreach ($data->record as $record) { $aar = new ADODB_Active_Record($table); $aar->bID = $b->getBlockID(); foreach ($record->children() as $node) { $nodeName = $node->getName(); $aar->{$nodeName} = (string) $node; } if ($table == 'btFormQuestions') { $db = Loader::db(); $aar->questionSetId = $db->GetOne('select questionSetId from btForm where bID = ?', array($b->getBlockID())); $aar->qID = null; } $aar->Save(); } } } } } }
public function Save() { parent::Save(); if ($this->supporting_docs_links != null) { $this->supporting_docs_links->Save(); } }
function Save() { // Agregar el generador a la llave primaria en insercion // el generador debe llamarse GEN_(Campo PK) if (App::$base->driver == 'firebird') { $ids = $this->DB()->MetaPrimaryKeys($this->_table); // PK $id = count($ids) > 0 ? $ids[0] : ''; if (!$this->_saved && $id != '') { $id = strtolower($id); $gen = 'GEN_' . strtoupper($id); $this->{$id} = $this->DB()->GenID($gen); } } if (App::$base->driver == 'postgres' || App::$base->driver == 'postgres8') { $ids = $this->DB()->MetaPrimaryKeys($this->_table); // PK $id = count($ids) > 0 ? $ids[0] : ''; if (!$this->_saved && $id != '') { $gen = $this->_table . '_' . $id . '_seq'; //formato: tbl_nombretabla_id_campoid_seq $gen = strtolower($gen); $this->{$id} = $this->DB()->GenID($gen); } } parent::Save(); return $this; }
public function Save() { if ($this->entity_name != null && $this->entity_id != null) { echo 'management:Save - no entity_name or entity_id defined'; return false; } else { parent::Save(); } }
public function Save() { if ($this->clari_notes_record_number != null) { $this->Load("clari_notes_record_number = '{$this->clari_notes_record_number}'"); } else { $this->clari_notes_record_number = shn_create_uuid('clari_notes'); parent::Save(); } }
public function __construct($table = false, $pkeyarr = false, $db = false, $options = array()) { parent::__construct($table, $pkey, $db, $options); $this->entity = $table; $this->keyName = get_primary_key($this->entity); //$this->entity . '_record_number'; $this->loadMTNames(); $this->loadUserFieldNames(); }
public function Save() { $saveType = $this->getSaveType(); parent::Save(); if ($this->supporting_docs_meta != null) { $this->supporting_docs_meta->Save(); Log::saveLogDetails($this->_table, $this->doc_id, $saveType); } }
function __construct($table = false, $pkeyarr = false, $db = false) { global $ADODB_ASSOC_CASE, $_ADODB_ACTIVE_DBS; if ($db == false && is_object($pkeyarr)) { $db = $pkeyarr; $pkeyarr = false; } if (!$table) { $table = $this->_pluralize(get_class($this)); } if ($db) { $this->_dbat = ADODB_Active_Record::SetDatabaseAdapter($db); } else { $this->_dbat = sizeof($_ADODB_ACTIVE_DBS) - 1; } if ($this->_dbat < 0) { $this->Error("No database connection set; use ADOdb_Active_Record::SetDatabaseAdapter(\$db)", 'ADODB_Active_Record::__constructor'); } $this->_table = $table; $this->_tableat = $table; # reserved for setting the assoc value to a non-table name, eg. the sql string in future $this->UpdateActiveTable($pkeyarr); }
function belongsTo($foreignRef, $foreignKey = false, $parentKey = '') { global $inflector; $ar = new ADODB_Active_Record($this->_pluralize($foreignRef)); $ar->foreignName = $foreignRef; $ar->parentKey = $parentKey; $ar->UpdateActiveTable(); $ar->foreignKey = $foreignKey ? $foreignKey : $foreignRef . ADODB_Active_Record::$_foreignSuffix; $table =& $this->TableInfo(); $table->_belongsTo[$foreignRef] = $ar; # $this->$foreignRef = $this->_belongsTo[$foreignRef]; }
/** * Duplicates an attribute key */ public function duplicate($args = array()) { $ar = new ADODB_Active_Record('AttributeKeys'); $ar->Load('akID=?', array($this->akID)); $ar2 = clone $ar; $ar2->akID = null; foreach ($args as $key => $value) { $ar2->{$key} = $value; } $ar2->Insert(); $db = Loader::db(); $ak = new AttributeKey(); $ak->load($db->Insert_ID()); // now we duplicate the specific category fields $this->getController()->duplicateKey($ak); return $ak; }
<?php // using ActiveRecord to load and change record include "adodb/adodb.inc.php"; include 'adodb/adodb-active-record.inc.php'; $conn = ADONewConnection('mysql'); $conn->connect("localhost", "user", "password", "test"); ADODB_Active_Record::setDatabaseAdapter($conn); class User extends ADODB_Active_Record { } $user = new User(); $user->load("id=10"); //load the record where the id is 10 echo $user->name; $user->name = "Afif Mohiuddin"; //now update $user->save(); //and save the previously loaded record
protected function importAdditionalData($b, $blockNode) { if (isset($blockNode->data)) { foreach ($blockNode->data as $data) { if (strtoupper($data['table']) != strtoupper($this->getBlockTypeDatabaseTable())) { $table = (string) $data['table']; if (isset($data->record)) { foreach ($data->record as $record) { $aar = new ADODB_Active_Record($table); $aar->bID = $b->getBlockID(); foreach ($record->children() as $node) { $nodeName = $node->getName(); $aar->{$nodeName} = ContentImporter::getValue((string) $node); } $aar->Save(); } } } } } }
* Class for mt_blog (website) */ class Website extends Blog { function Save() { if (empty($this->blog_class)) { $this->blog_class = 'website'; } return parent::Save(); } function blogs() { $where = "blog_parent_id = " . $this->id; require_once 'class.mt_blog.php'; $blog = new Blog(); $blogs = $blog->Find($where); return $blogs; } function site_path() { return $this->blog_site_path; } function site_url() { return $this->blog_site_url; } } // Relations ADODB_Active_Record::ClassHasMany('Website', 'mt_blog_meta', 'blog_meta_blog_id');
# Movable Type (r) (C) 2001-2015 Six Apart, Ltd. All Rights Reserved. # This code cannot be redistributed without permission from www.sixapart.com. # For more information, consult your Movable Type license. # # $Id$ require_once "class.baseobject.php"; /*** * Class for mt_tbping */ class TBPing extends BaseObject { public $_table = 'mt_tbping'; protected $_prefix = "tbping_"; protected $_has_meta = true; public function trackback() { $col_name = "tbping_tb_id"; ${$tb} = null; if (isset($this->{$col_name}) && is_numeric($this->{$col_name})) { $tb_id = $this->{$col_name}; require_once 'class.mt_trackback.php'; $tb = new Trackback(); $tb->Load("trackback_id = {$tb_id}"); } return $tb; } } // Relations ADODB_Active_Record::ClassHasMany('TBPing', 'mt_tbping_meta', 'tbping_meta_tbping_id');
<?php class Document extends ADOdb_Active_Record { // // Callback function hook for when document gets a 'created' status from document_callback.php // function createdCallback($http_body) { error_log("Document {$this->id} created"); $xml = simplexml_load_string($http_body); } // // Callback function hook for when document gets a 'viewed' status from document_callback.php // function viewedCallback($http_body) { error_log("Document {$this->id} viewed"); $xml = simplexml_load_string($http_body); } // // Callback function hook for when document gets a 'signed' status from document_callback.php // function completedCallback($http_body) { error_log("Document {$this->id} completed"); $xml = simplexml_load_string($http_body); } } ADODB_Active_Record::ClassBelongsTo('document', 'user', 'user_id', 'id');
static function TableKeyHasMany($table, $tablePKey, $foreignRef, $foreignKey = false, $foreignClass = 'ADODB_Active_Record') { if (!is_array($tablePKey)) { $tablePKey = array($tablePKey); } $ar = new ADODB_Active_Record($table, $tablePKey); $ar->hasMany($foreignRef, $foreignKey, $foreignClass); }
<?php class Template extends ADOdb_Active_Record { } ADODB_Active_Record::ClassHasMany('template', 'templates', 'user_id');
$person->favorite_color = 'lavender'; $person->save(); // this save will perform an INSERT successfully $person2 = new person(); $person2->Load('id=1'); $c = $person2->children; if (is_array($c) && sizeof($c) == 3 && $c[0]->name_first == 'Jill' && $c[1]->name_first == 'Joan' && $c[2]->name_first == 'JAMIE') { echo "OK Loaded HasMany</br>"; } else { var_dump($c); echo "error loading hasMany should have 3 array elements Jill Joan Jamie<br>"; } class child extends ADOdb_Active_Record { } ADODB_Active_Record::TableBelongsTo('children', 'person', 'person_id', 'id'); $ch = new Child('children', array('id')); $ch->Load('id=1'); if ($ch->name_first !== 'Jill') { echo "error in Loading Child<br>"; } $p = $ch->person; if (!$p || $p->name_first != 'John') { echo "Error loading belongsTo<br>"; } else { echo "OK loading BelongTo<br>"; } if ($p) { #$p->HasMany('children','person_id'); ## this is affects all other instances of Person $p->LoadRelations('children', 'order by id', 1, 2); if (sizeof($p->children) == 2 && $p->children[1]->name_first == 'JAMIE') {
public function __construct($table = false, $pkeyarr = false, $db = false, $options = array()) { parent::__construct('mt_vocab', $pkey, $db, $options); }
} require_once 'class.mt_trackback.php'; $trackback = new Trackback(); $loaded = $trackback->Load("trackback_entry_id = " . $this->entry_id); if (!$loaded) { $trackback = null; } return $trackback; } public function pings() { $pings = array(); $tb = $this->trackback(); if (!empty($tb)) { require_once 'class.mt_tbping.php'; $tbping = new TBPing(); $pings = $tbping->Find("tbping_tb_id = " . $tb->id); } return $pings; } function Save() { if (empty($this->entry_class)) { $this->class = 'entry'; } return parent::Save(); } } // Relations ADODB_Active_Record::ClassHasMany('Entry', 'mt_entry_meta', 'entry_meta_entry_id');
public function __construct($table = false, $pkeyarr = false, $db = false, $options = array()) { parent::__construct($table, $pkey, $db, $options); $this->belongsTo('user', 'username', 'username'); }
public function duplicate() { $dh = Loader::helper('date'); $db = Loader::db(); $date = $dh->getSystemDateTime(); $far = new ADODB_Active_Record('Files'); $far->Load('fID=?', array($this->fID)); $far2 = clone $far; $far2->fID = null; $far2->fDateAdded = $date; $far2->Insert(); $fIDNew = $db->Insert_ID(); $fvIDs = $db->GetCol('select fvID from FileVersions where fID = ?', $this->fID); foreach($fvIDs as $fvID) { $farv = new ADODB_Active_Record('FileVersions'); $farv->Load('fID=? and fvID = ?', array($this->fID, $fvID)); $farv2 = clone $farv; $farv2->fID = $fIDNew; $farv2->fvActivateDatetime = $date; $farv2->fvDateAdded = $date; $farv2->Insert(); } $r = $db->Execute('select fvID, akID, avID from FileAttributeValues where fID = ?', array($this->getFileID())); while ($row = $r->fetchRow()) { $db->Execute("insert into FileAttributeValues (fID, fvID, akID, avID) values (?, ?, ?, ?)", array( $fIDNew, $row['fvID'], $row['akID'], $row['avID'] )); } // return the new file object return File::getByID($fIDNew); }
if (!empty($tb)) { require_once 'class.mt_tbping.php'; $tbping = new TBPing(); $pings = $tbping->Find("tbping_tb_id = " . $tb->id); } return $pings; } public function Save() { if (empty($this->category_class)) { $this->class = 'category'; } parent::Save(); } public function entry_count() { $child_class = $this->class === 'category' ? 'entry' : 'page'; $blog_id = $this->blog_id; $cat_id = $this->id; $where = "entry_status = 2\n and entry_class = '{$child_class}'\n and entry_blog_id = {$blog_id}"; $join = array(); $join['mt_placement'] = array('condition' => "placement_entry_id = entry_id and placement_category_id = {$cat_id}"); require_once 'class.mt_entry.php'; $entry = new Entry(); $cnt = $entry->count(array('where' => $where, 'join' => $join)); return $cnt; } } // Relations ADODB_Active_Record::ClassHasMany('Category', 'mt_category_meta', 'category_meta_category_id');
# Movable Type (r) (C) 2001-2014 Six Apart, Ltd. All Rights Reserved. # This code cannot be redistributed without permission from www.sixapart.com. # For more information, consult your Movable Type license. # # $Id$ require_once "class.baseobject.php"; /*** * Class for mt_comment */ class Comment extends BaseObject { public $_table = 'mt_comment'; protected $_prefix = "comment_"; protected $_has_meta = true; public function commenter() { $commenter_id = $this->comment_commenter_id; if (empty($commenter_id) || !is_numeric($commenter_id)) { return; } require_once 'class.mt_author.php'; $author = new Author(); if ($author->Load("author_id = {$commenter_id}")) { return $author; } return null; } } // Relations ADODB_Active_Record::ClassHasMany('Comment', 'mt_comment_meta', 'comment_meta_comment_id');
<?php # Movable Type (r) (C) 2001-2015 Six Apart, Ltd. All Rights Reserved. # This code cannot be redistributed without permission from www.sixapart.com. # For more information, consult your Movable Type license. # # $Id$ require_once "class.baseobject.php"; /*** * Class for mt_asset */ class Asset extends BaseObject { public $_table = 'mt_asset'; protected $_prefix = "asset_"; protected $_has_meta = true; } // Relations ADODB_Active_Record::ClassHasMany('Asset', 'mt_asset_meta', 'asset_meta_asset_id');
public function Save() { $saveType = $this->getSaveType(); parent::Save(); Log::saveLogDetails($this->_table, $this->doc_id, $saveType); }
public function __construct($table = false, $pkeyarr = false, $db = false, $options = array()) { $table = 'mt_index'; parent::__construct($table, $pkey, $db, $options); }
$db = NewADOConnection('postgres'); $db->Connect("localhost", "tester", "test", "test"); } else { $db = NewADOConnection('oci8://scott:natsoft@/'); } } $arr = $db->ServerInfo(); echo "<h3>{$db->dataProvider}: {$arr['description']}</h3>"; $arr = $db->GetActiveRecords('products', ' productid<10'); adodb_pr($arr); ADOdb_Active_Record::SetDatabaseAdapter($db); if (!$db) { die('failed'); } $rec = new ADODB_Active_Record('photos'); $rec = new ADODB_Active_Record('products'); adodb_pr($rec->getAttributeNames()); echo "<hr>"; $rec->load('productid=2'); adodb_pr($rec); $db->debug = 1; $rec->productname = 'Changie Chan' . rand(); $rec->insert(); $rec->update(); $rec->productname = 'Changie Chan 99'; $rec->replace(); $rec2 = new ADODB_Active_Record('products'); $rec->load('productid=3'); $rec->save(); $rec = new ADODB_Active_record('products'); $rec->productname = 'John ActiveRec';
/** * ar->foreignName will contain the name of the tables associated with this table because * this table's rows may also be referenced by those tables using thistable_id or the provided * foreign keys (this index name is stored in ar->foreignKey) * * this-table.other-table_id = other-table.id */ function belongsTo($foreignRef, $foreignKey = false) { global $inflector; $ar = new ADODB_Active_Record($this->_pluralize($foreignRef)); $ar->foreignName = $foreignRef; $ar->UpdateActiveTable(); $ar->foreignKey = $foreignKey ? $foreignKey : $ar->foreignName . self::$_foreignSuffix; $table =& $this->TableInfo(); if (!isset($table->_belongsTo[$foreignRef])) { $table->_belongsTo[$foreignRef] = $ar; $table->updateColsCount(); } $this->{$foreignRef} = $table->_belongsTo[$foreignRef]; }
public function Save() { parent::Save(); }