当前位置: 首页>>代码示例>>PHP>>正文


PHP Manager::getDatabase方法代码示例

本文整理汇总了PHP中Manager::getDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP Manager::getDatabase方法的具体用法?PHP Manager::getDatabase怎么用?PHP Manager::getDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Manager的用法示例。


在下文中一共展示了Manager::getDatabase方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($module, $item, $value, $defaults = null)
 {
     $this->value = $value;
     $this->module = $module;
     $this->item = $item;
     $this->defaults = $defaults;
     parent::__construct($module);
     if (file_exists(Manager::getModulePath($module, 'db/lookup.class')) && Manager::uses('/db/lookup.class', $module) || Manager::uses('/classes/lookup.class', $module)) {
         eval("\$object = new Business{$module}Lookup();");
         eval("\$info   = \$object->autoComplete{$item}(\$this,\$defaults);");
         parent::__construct($this->module);
         if ($info) {
             $this->result = $info;
         } else {
             //faz consulta
             $sql = new Msql('');
             $sql->createFrom($this->sql);
             $sql->prepare($value);
             $db = Manager::getDatabase($this->module);
             //$this->sql = MSql::prepare($this->sql,$value);
             //$result = $this->_db->query($value ? $sql->command : str_replace('?','NULL',$this->sql));
             $result = $db->query($value ? $sql->command : str_replace('?', 'NULL', $this->sql));
             $this->result = $result[0];
         }
     }
 }
开发者ID:joshuacoddingyou,项目名称:php,代码行数:26,代码来源:mautocomplete.php

示例2: getDatabase

 public function getDatabase($name)
 {
     return Manager::getDatabase($name);
 }
开发者ID:joshuacoddingyou,项目名称:php,代码行数:4,代码来源:mservice.php

示例3: handlerDb

 /**
  * Brief Description.
  * Complete Description.
  *
  * @param $msg (tipo) desc
  *
  * @returns (tipo) desc
  *
  */
 private function handlerDb($msg)
 {
     $login = Manager::getLogin();
     $uid = $login ? $login->getLogin() : '';
     $ts = Manager::getSysTime();
     $db = Manager::getDatabase('manager');
     $idLog = $db->getNewId('seq_manager_log');
     $sql = new MSQL('idlog, timestamp, login, msg, host', 'manager_log');
     $db->execute($sql->insert(array($idLog, $ts, $uid, $msg, $this->host)));
 }
开发者ID:joshuacoddingyou,项目名称:php,代码行数:19,代码来源:mlog.php

示例4: generate

 public function generate()
 {
     $db = Manager::getDatabase($this->databaseName);
     $pf = $db->getPlatForm();
     $queryTables = $db->getQueryCommand($pf->getListTablesSQL());
     foreach ($queryTables->getResult() as $tables) {
         $table = $tables[0];
         $classes[$table]['name'] = $table;
         $queryColumns = $db->getQueryCommand($pf->getListTableColumnsSQL("`" . $table . "`"));
         $pk = 0;
         $binding = false;
         foreach ($queryColumns->getResult() as $column) {
             $col = "attributes['" . $column[0] . "'] = " . '"' . $column[0] . ',' . $this->getType($column[1]) . ',';
             $col .= ($column[2] == 'NO' ? 'not null' : '') . ',';
             if ($column[3] == 'PRI') {
                 ++$pk;
             }
             $col .= $column[3] == 'PRI' ? 'primary' : ($column[3] == 'MUL' ? 'foreign' : '');
             $col .= ($column[5] == 'auto_increment' ? ',identity' : '') . '"';
             $classes[$table]['columns'][] = $col;
         }
         if ($pk > 1) {
             $binding = $classes[$table]['binding'] = true;
         }
         $queryFK = $db->getQueryCommand($pf->getListTableForeignKeysSQL($table, $db->getConfig('dbname')));
         foreach ($queryFK->getResult() as $fk) {
             $associationName = str_ireplace('fk_', '', $fk[0]);
             $associationName = str_ireplace('has_', '', $associationName);
             $associationName = str_ireplace("{$table}_", '', $associationName);
             $associationName = str_ireplace(array('1', '2', '3'), '', $associationName);
             $associationName = strtolower($associationName);
             if (!$binding) {
                 $assoc = "association['" . $associationName . "'] = " . '"\\' . $this->appName . "\\models\\" . $fk[2] . ',';
                 $assoc .= "oneToOne," . $fk[1] . ':' . $fk[3] . '"';
                 $classes[$table]['associations'][$associationName] = $assoc;
                 // cria a inversa oneToMany
                 $associationName2 = ($fk[2] != $associationName ? $table . $associationName : $table) . 's';
                 $assoc2 = "association['" . $associationName2 . "'] = " . '"\\' . $this->appName . "\\models\\" . $table . ',oneToMany,' . $fk[3] . ':' . $fk[1] . '"';
                 $classes[$fk[2]]['associations'][$associationName2] = $assoc2;
             } else {
                 $classes[$table]['associations'][$associationName] = $fk[2];
             }
         }
         if ($binding) {
             // cria as inversas manyToMany
             foreach ($classes[$table]['associations'] as $associationName => $tableRef) {
                 foreach ($classes[$table]['associations'] as $associationName2 => $tableRef2) {
                     if ($associationName != $associationName2) {
                         $assoc2 = "association['" . $associationName2 . 's' . "'] = " . '"\\' . $this->appName . "\\models\\" . $tableRef2 . ',manyToMany,' . $table . '"';
                         $classes[$tableRef]['associations'][$associationName . 's'] = $assoc2;
                     }
                 }
             }
         }
     }
     $dbName = $this->databaseName;
     $moduleName = $this->moduleName;
     $document = array();
     $document[] = "[globals]";
     $document[] = "database = \"{$dbName}\"";
     $document[] = "app = \"{$this->appName}\"";
     $document[] = "module = \"{$this->moduleName}\"";
     $document[] = '';
     foreach ($classes as $class) {
         if ($class['name'] != '' && !$class['binding']) {
             $document[] = '[' . $class['name'] . ']';
             $document[] = 'table = "' . $class['name'] . '"';
             foreach ($class['columns'] as $column) {
                 $document[] = $column;
             }
             foreach ($class['associations'] as $association) {
                 $document[] = $association;
             }
             $document[] = '';
         }
     }
     $map = implode("\n", $document);
     $filename = $this->baseDir . '/' . $this->fileScript;
     file_put_contents($filename, $map);
 }
开发者ID:joshuacoddingyou,项目名称:php,代码行数:80,代码来源:MReverseMySQL.php


注:本文中的Manager::getDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。