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


PHP CakeSchema::after方法代碼示例

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


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

示例1: _run

 /**
  * Runs sql from _create() or _update()
  *
  * @param array $contents
  * @param string $event
  * @param CakeSchema $Schema
  * @return void
  */
 protected function _run($contents, $event, &$Schema)
 {
     if (empty($contents)) {
         $this->err(__d('cake_console', 'Sql could not be run'));
         return;
     }
     Configure::write('debug', 2);
     $db = ConnectionManager::getDataSource($this->Schema->connection);
     foreach ($contents as $table => $sql) {
         if (empty($sql)) {
             $this->out(__d('cake_console', '%s is up to date.', $table));
         } else {
             if ($this->_dry === true) {
                 $this->out(__d('cake_console', 'Dry run for %s :', $table));
                 $this->out($sql);
             } else {
                 if (!$Schema->before(array($event => $table))) {
                     return false;
                 }
                 $error = null;
                 try {
                     $db->execute($sql);
                 } catch (PDOException $e) {
                     $error = $table . ': ' . $e->getMessage();
                 }
                 $Schema->after(array($event => $table, 'errors' => $error));
                 if (!empty($error)) {
                     $this->err($error);
                 } else {
                     $this->out(__d('cake_console', '%s updated.', $table));
                 }
             }
         }
     }
 }
開發者ID:sanyaade-machine-learning,項目名稱:Catool,代碼行數:43,代碼來源:SchemaShell.php

示例2: _runSchema

 /**
  * Runs sql from _createSchema()
  *
  * NOTE: adapted from the schema shell lib/Cake/Console/Command/SchemaShell.php
  *
  * @param array $contents
  * @param string $event
  * @param CakeSchema $Schema
  * @return string
  */
 protected function _runSchema($db, $contents, $event, &$Schema)
 {
     $out = '';
     if (empty($contents)) {
         $this->error('Sql could not be run');
         return false;
     }
     foreach ($contents as $table => $sql) {
         if (empty($sql)) {
             $out .= sprintf("%s is up to date.\n", $table);
         } else {
             if (!$Schema->before(array($event => $table))) {
                 return false;
             }
             $error = null;
             try {
                 $db->execute($sql);
             } catch (PDOException $e) {
                 $error = $table . ': ' . $e->getMessage();
             }
             $Schema->after(array($event => $table, 'errors' => $error));
             if (!empty($error)) {
                 $this->error($error);
                 return false;
             } else {
                 $out .= sprintf("%s updated\n", $table);
             }
         }
     }
     return $out;
 }
開發者ID:sanyaade-machine-learning,項目名稱:Catool,代碼行數:41,代碼來源:install.php


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