當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DB_DataObject::_connect方法代碼示例

本文整理匯總了PHP中DB_DataObject::_connect方法的典型用法代碼示例。如果您正苦於以下問題:PHP DB_DataObject::_connect方法的具體用法?PHP DB_DataObject::_connect怎麽用?PHP DB_DataObject::_connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DB_DataObject的用法示例。


在下文中一共展示了DB_DataObject::_connect方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _connect

 public function _connect()
 {
     // avoid those annoying PEAR::DB strict standards warnings it causes
     $old = error_reporting();
     error_reporting(error_reporting() & ~E_STRICT);
     $res = parent::_connect();
     // reset
     error_reporting($old);
     return $res;
 }
開發者ID:bashrc,項目名稱:gnusocial-debian,代碼行數:10,代碼來源:GS_DataObject.php

示例2: joinAdd

 /**
  * joinAdd - adds another dataobject to this, building a joined query.
  *
  * example (requires links.ini to be set up correctly)
  * // get all the images for product 24
  * $i = new DataObject_Image();
  * $pi = new DataObjects_Product_image();
  * $pi->product_id = 24; // set the product id to 24
  * $i->joinAdd($pi); // add the product_image connectoin
  * $i->find();
  * while ($i->fetch()) {
  *     // do stuff
  * }
  * // an example with 2 joins
  * // get all the images linked with products or productgroups
  * $i = new DataObject_Image();
  * $pi = new DataObject_Product_image();
  * $pgi = new DataObject_Productgroup_image();
  * $i->joinAdd($pi);
  * $i->joinAdd($pgi);
  * $i->find();
  * while ($i->fetch()) {
  *     // do stuff
  * }
  *
  *
  * @param    optional $obj       object |array    the joining object (no value resets the join)
  *                                          If you use an array here it should be in the format:
  *                                          array('local_column','remotetable:remote_column');
  *                                          if remotetable does not have a definition, you should
  *                                          use @ to hide the include error message..
  *                                      
  *
  * @param    optional $joinType  string | array
  *                                          'LEFT'|'INNER'|'RIGHT'|'' Inner is default, '' indicates 
  *                                          just select ... from a,b,c with no join and 
  *                                          links are added as where items.
  *                                          
  *                                          If second Argument is array, it is assumed to be an associative
  *                                          array with arguments matching below = eg.
  *                                          'joinType' => 'INNER',
  *                                          'joinAs' => '...'
  *                                          'joinCol' => ....
  *                                          'useWhereAsOn' => false,
  *
  * @param    optional $joinAs    string     if you want to select the table as anther name
  *                                          useful when you want to select multiple columsn
  *                                          from a secondary table.
  * @param    optional $joinCol   string     The column on This objects table to match (needed
  *                                          if this table links to the child object in 
  *                                          multiple places eg.
  *                                          user->friend (is a link to another user)
  *                                          user->mother (is a link to another user..)
  *
  *           optional 'useWhereAsOn' bool   default false;
  *                                          convert the where argments from the object being added
  *                                          into ON arguments.
  * 
  * 
  * @return   none
  * @access   public
  * @author   Stijn de Reede      <sjr@gmx.co.uk>
  */
 function joinAdd($obj = false, $joinType = 'INNER', $joinAs = false, $joinCol = false)
 {
     global $_DB_DATAOBJECT;
     if ($obj === false) {
         $this->_join = '';
         return;
     }
     //echo '<PRE>'; print_r(func_get_args());
     $useWhereAsOn = false;
     // support for 2nd argument as an array of options
     if (is_array($joinType)) {
         // new options can now go in here... (dont forget to document them)
         $useWhereAsOn = !empty($joinType['useWhereAsOn']);
         $joinCol = isset($joinType['joinCol']) ? $joinType['joinCol'] : $joinCol;
         $joinAs = isset($joinType['joinAs']) ? $joinType['joinAs'] : $joinAs;
         $joinType = isset($joinType['joinType']) ? $joinType['joinType'] : 'INNER';
     }
     // support for array as first argument
     // this assumes that you dont have a links.ini for the specified table.
     // and it doesnt exist as am extended dataobject!! - experimental.
     $ofield = false;
     // object field
     $tfield = false;
     // this field
     $toTable = false;
     if (is_array($obj)) {
         $tfield = $obj[0];
         list($toTable, $ofield) = explode(':', $obj[1]);
         $obj = DB_DataObject::factory($toTable);
         if (!$obj || is_a($obj, 'PEAR_Error')) {
             $obj = new DB_DataObject();
             $obj->__table = $toTable;
         }
         $obj->_connect();
         // set the table items to nothing.. - eg. do not try and match
         // things in the child table...???
         $items = array();
//.........這裏部分代碼省略.........
開發者ID:bigpussy,項目名稱:statusnet,代碼行數:101,代碼來源:DataObject.php

示例3: joinAdd

 /**
  * joinAdd - adds another dataobject to this, building a joined query.
  *
  * example (requires links.ini to be set up correctly)
  * // get all the images for product 24
  * $i = new DataObject_Image();
  * $pi = new DataObjects_Product_image();
  * $pi->product_id = 24; // set the product id to 24
  * $i->joinAdd($pi); // add the product_image connectoin
  * $i->find();
  * while ($i->fetch()) {
  *     // do stuff
  * }
  * // an example with 2 joins
  * // get all the images linked with products or productgroups
  * $i = new DataObject_Image();
  * $pi = new DataObject_Product_image();
  * $pgi = new DataObject_Productgroup_image();
  * $i->joinAdd($pi);
  * $i->joinAdd($pgi);
  * $i->find();
  * while ($i->fetch()) {
  *     // do stuff
  * }
  *
  *
  * @param    optional $obj       object |array    the joining object (no value resets the join)
  *                                          If you use an array here it should be in the format:
  *                                          array('local_column','remotetable:remote_column');
  *                                          if remotetable does not have a definition, you should
  *                                          use @ to hide the include error message..
  *                                      
  *
  * @param    optional $joinType  string     'LEFT'|'INNER'|'RIGHT'|'' Inner is default, '' indicates 
  *                                          just select ... from a,b,c with no join and 
  *                                          links are added as where items.
  *
  * @param    optional $joinAs    string     if you want to select the table as anther name
  *                                          useful when you want to select multiple columsn
  *                                          from a secondary table.
  * @param    optional $joinCol   string     The column on This objects table to match (needed
  *                                          if this table links to the child object in 
  *                                          multiple places eg.
  *                                          user->friend (is a link to another user)
  *                                          user->mother (is a link to another user..)
  *
  * @return   none
  * @access   public
  * @author   Stijn de Reede      <sjr@gmx.co.uk>
  */
 function joinAdd($obj = false, $joinType = 'INNER', $joinAs = false, $joinCol = false)
 {
     global $_DB_DATAOBJECT;
     if ($obj === false) {
         $this->_join = '';
         return;
     }
     // support for array as first argument
     // this assumes that you dont have a links.ini for the specified table.
     // and it doesnt exist as am extended dataobject!! - experimental.
     $ofield = false;
     // object field
     $tfield = false;
     // this field
     $toTable = false;
     if (is_array($obj)) {
         $tfield = $obj[0];
         list($toTable, $ofield) = explode(':', $obj[1]);
         $obj = DB_DataObject::factory($toTable);
         if (!$obj || is_a($obj, 'PEAR_Error')) {
             $obj = new DB_DataObject();
             $obj->__table = $toTable;
         }
         $obj->_connect();
         // set the table items to nothing.. - eg. do not try and match
         // things in the child table...???
         $items = array();
     }
     if (!is_object($obj)) {
         $this->raiseError("joinAdd: called without an object", DB_DATAOBJECT_ERROR_NODATA, PEAR_ERROR_DIE);
     }
     /*  make sure $this->_database is set.  */
     $this->_connect();
     $DB =& $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
     /* look up the links for obj table */
     //print_r($obj->links());
     if (!$ofield && ($olinks = $obj->links())) {
         foreach ($olinks as $k => $v) {
             /* link contains {this column} = {linked table}:{linked column} */
             $ar = explode(':', $v);
             if ($ar[0] == $this->__table) {
                 // you have explictly specified the column
                 // and the col is listed here..
                 // not sure if 1:1 table could cause probs here..
                 if ($joinCol !== false) {
                     $this->raiseError("joinAdd: You cannot target a join column in the " . "'link from' table ({$obj->__table}). " . "Either remove the fourth argument to joinAdd() " . "({$joinCol}), or alter your links.ini file.", DB_DATAOBJECT_ERROR_NODATA);
                     return false;
                 }
                 $ofield = $k;
                 $tfield = $ar[1];
//.........這裏部分代碼省略.........
開發者ID:bhirsch,項目名稱:voipdrupal-4.7-1.0,代碼行數:101,代碼來源:DataObject.php

示例4:

 /**
  * Added storing reference to DataBase connection
  *
  * @todo Add sharing connections in connection Pool
  * @see DB_DataObject::_connect()
  *
  * @return PEAR_Error | true
  */
 function _connect()
 {
     if ($this->_database_dsn_md5 && !empty($GLOBALS['_DB_DATAOBJECT']['CONNECTIONS'][$this->_database_dsn_md5]) && $this->_database) {
         return true;
     }
     if (empty($_DB_DATAOBJECT['CONFIG'])) {
         $this->_loadConfig();
     }
     $dbh =& OA_DB::singleton();
     if (PEAR::isError($dbh)) {
         return $dbh;
     }
     $this->_database_dsn_md5 = md5(OA_DB::getDsn());
     $GLOBALS['_DB_DATAOBJECT']['CONNECTIONS'][$this->_database_dsn_md5] =& $dbh;
     $GLOBALS['_DB_DATAOBJECT']['CONFIG']['quote_identifiers'] = $dbh->options['quote_identifier'];
     $this->_database = $dbh->getDatabase();
     // store the reference in ADMIN_DB_LINK - backward compatibility
     $GLOBALS['_MAX']['ADMIN_DB_LINK'] =& $dbh->connection;
     return parent::_connect();
 }
開發者ID:Spark-Eleven,項目名稱:revive-adserver,代碼行數:28,代碼來源:DB_DataObjectCommon.php

示例5: factory

 /**
  * classic factory method for loading a table class
  * usage: $do = DB_DataObject::factory('person')
  * WARNING - this may emit a include error if the file does not exist..
  * use @ to silence it (if you are sure it is acceptable)
  * eg. $do = @DB_DataObject::factory('person')
  *
  * table name will eventually be databasename/table
  * - and allow modular dataobjects to be written..
  * (this also helps proxy creation)
  *
  *
  * @param  string  $table  tablename (use blank to create a new instance of the same class.)
  * @access private
  * @return DataObject|PEAR_Error 
  */
 function factory($table = '')
 {
     global $_DB_DATAOBJECT;
     if (empty($_DB_DATAOBJECT['CONFIG'])) {
         DB_DataObject::_loadConfig();
     }
     if ($table === '') {
         if (is_a($this, 'DB_DataObject') && strlen($this->__table)) {
             $table = $this->__table;
         } else {
             return DB_DataObject::raiseError("factory did not recieve a table name", DB_DATAOBJECT_ERROR_INVALIDARGS);
         }
     }
     $p = isset($_DB_DATAOBJECT['CONFIG']['class_prefix']) ? $_DB_DATAOBJECT['CONFIG']['class_prefix'] : '';
     $class = $p . preg_replace('/[^A-Z0-9]/i', '_', ucfirst($table));
     $class = class_exists($class) ? $class : DB_DataObject::_autoloadClass($class);
     // proxy = full|light
     if (!$class && isset($_DB_DATAOBJECT['CONFIG']['proxy'])) {
         $proxyMethod = 'getProxy' . $_DB_DATAOBJECT['CONFIG']['proxy'];
         require_once 'DB/DataObject/Generator.php';
         $d = new DB_DataObject();
         $d->__table = $table;
         $d->_connect();
         $x = new DB_DataObject_Generator();
         return $x->{$proxyMethod}($d->_database, $table);
     }
     if (!$class) {
         return DB_DataObject::raiseError("factory could not find class {$class} from {$table}", DB_DATAOBJECT_ERROR_INVALIDCONFIG);
     }
     return new $class();
 }
開發者ID:BackupTheBerlios,項目名稱:urulu-svn,代碼行數:47,代碼來源:DataObject.php


注:本文中的DB_DataObject::_connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。