当前位置: 首页>>代码示例>>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;未经允许,请勿转载。