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


PHP Fuel::clean_path方法代码示例

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


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

示例1: inspect

    /**
     * Quick and nice way to output a mixed variable to the browser
     *
     * @static
     * @access	public
     * @return	string
     */
    public static function inspect()
    {
        $backtrace = debug_backtrace();
        // If being called from within, show the file above in the backtrack
        if (strpos($backtrace[0]['file'], 'core/classes/debug.php') !== FALSE) {
            $callee = $backtrace[1];
            $label = \Inflector::humanize($backtrace[1]['function']);
        } else {
            $callee = $backtrace[0];
            $label = 'Debug';
        }
        $arguments = func_get_args();
        $total_arguments = count($arguments);
        $callee['file'] = \Fuel::clean_path($callee['file']);
        if (!static::$js_displayed) {
            echo <<<JS
<script type="text/javascript">function fuel_debug_toggle(a){if(document.getElementById){if(document.getElementById(a).style.display=="none"){document.getElementById(a).style.display="block"}else{document.getElementById(a).style.display="none"}}else{if(document.layers){if(document.id.display=="none"){document.id.display="block"}else{document.id.display="none"}}else{if(document.all.id.style.display=="none"){document.all.id.style.display="block"}else{document.all.id.style.display="none"}}}};</script>
JS;
            static::$js_displayed = true;
        }
        echo '<div style="font-size: 13px;background: #EEE !important; border:1px solid #666; color: #000 !important; padding:10px;">';
        echo '<h1 style="border-bottom: 1px solid #CCC; padding: 0 0 5px 0; margin: 0 0 5px 0; font: bold 120% sans-serif;">' . $callee['file'] . ' @ line: ' . $callee['line'] . '</h1>';
        echo '<pre style="overflow:auto;font-size:100%;">';
        $i = 0;
        foreach ($arguments as $argument) {
            echo '<strong>' . $label . ' #' . ++$i . ' of ' . $total_arguments . '</strong>:<br />';
            echo static::format('...', $argument);
            echo '<br />';
        }
        echo "</pre>";
        echo "</div>";
    }
开发者ID:quickpacket,项目名称:noclayer,代码行数:39,代码来源:debug.php

示例2: load

 /**
  * Loads the given package.  If a path is not given, then PKGPATH is used.
  * It also accepts an array of packages as the first parameter.
  *
  * @param   string|array  $package  The package name or array of packages.
  * @param   string|null   $path     The path to the package
  * @return  bool  True on success
  * @throws  PackageNotFoundException
  */
 public static function load($package, $path = null)
 {
     if (is_array($package)) {
         foreach ($package as $pkg) {
             $path = null;
             if (is_array($pkg)) {
                 list($pkg, $path) = $pkg;
             }
             static::load($pkg, $path);
         }
         return false;
     }
     if (static::loaded($package)) {
         return;
     }
     // Load it from PKGPATH if no path was given.
     if ($path === null) {
         $path = PKGPATH . $package . DS;
     }
     if (!is_dir($path)) {
         throw new \PackageNotFoundException("Package '{$package}' could not be found at '" . \Fuel::clean_path($path) . "'");
     }
     \Finder::instance()->add_path($path, 1);
     \Fuel::load($path . 'bootstrap.php');
     static::$packages[$package] = $path;
     return true;
 }
开发者ID:quickpacket,项目名称:noclayer,代码行数:36,代码来源:package.php

示例3: load

 /**
  * Loads the given package.
  * If a path is not given, if will search through
  * the defined package_paths. If not defined, then PKGPATH is used.
  * It also accepts an array of packages as the first parameter.
  *
  * @param string|array $package
  *        	The package name or array of packages.
  * @param string|null $path
  *        	The path to the package
  * @return bool True on success
  * @throws PackageNotFoundException
  */
 public static function load($package, $path = null)
 {
     if (is_array($package)) {
         foreach ($package as $pkg => $path) {
             if (is_numeric($pkg)) {
                 $pkg = $path;
                 $path = null;
             }
             static::load($pkg, $path);
         }
         return false;
     }
     if (static::loaded($package)) {
         return;
     }
     // if no path is given, try to locate the package
     if ($path === null) {
         $paths = \Config::get('package_paths', array());
         empty($paths) and $paths = array(PKGPATH);
         if (!empty($paths)) {
             foreach ($paths as $modpath) {
                 if (is_dir($path = $modpath . strtolower($package) . DS)) {
                     break;
                 }
             }
         }
     }
     if (!is_dir($path)) {
         throw new \PackageNotFoundException("Package '{$package}' could not be found at '" . \Fuel::clean_path($path) . "'");
     }
     \Finder::instance()->add_path($path, 1);
     \Fuel::load($path . 'bootstrap.php');
     static::$packages[$package] = $path;
     return true;
 }
开发者ID:vienbk91,项目名称:fuelphp17,代码行数:48,代码来源:package.php

示例4: to

 /**
  * passes the data to the template and returns the result
  *
  * @param 	string 	$template_file	the template file used to structure the data
  * @return 	array	the restructured data
  */
 public function to($template)
 {
     $template_folder = \Config::get('structure.templates_folder');
     $template_path = \Fuel::find_file($template_folder, $template);
     if (!$template_path) {
         throw new \Fuel_Exception('The requested template could not be found: ' . \Fuel::clean_path($file));
     }
     $data = static::capture($template_path, $this->_data);
     return static::capture($template_path, $this->_data);
 }
开发者ID:JaapRood,项目名称:fuel-structure,代码行数:16,代码来源:structure.php

示例5: action_index

 public function action_index($page = 'petro')
 {
     $dir = APPPATH . 'views';
     $file = '/dashboard/' . $page . '.md';
     $path = \Fuel::clean_path($dir . $file);
     // var_dump($dir, $file, $path);
     // var_dump(\Finder::instance()->locate($dir, 'dashboard/index'));  die;
     $data['text'] = \View::forge('dashboard/' . $page . '.md');
     $this->template->content = \View::forge('dashboard/index', $data);
 }
开发者ID:ratiw,项目名称:petro-test,代码行数:10,代码来源:_dashboard.php

示例6: write

 private function write($filepath, $data)
 {
     if (!($handle = fopen($filepath, 'w+'))) {
         throw new Exception('Cannot open file: ' . \Fuel::clean_path($filepath));
     }
     $result = @fwrite($handle, $data);
     // Write $somecontent to our opened file.
     if ($result === FALSE) {
         throw new Exception('Cannot write to file: ' . \Fuel::clean_path($filepath));
     }
     @fclose($handle);
     chmod($filepath, 0666);
     return $result;
 }
开发者ID:hymns,项目名称:fuel,代码行数:14,代码来源:scaffold.php

示例7: load

 /**
  * Loads the given module.  If a path is not given, then 'module_paths' is used.
  * It also accepts an array of modules as the first parameter.
  *
  * @param   string|array  $package  The module name or array of modules.
  * @param   string|null   $path     The path to the module
  * @return  bool  True on success
  * @throws  ModuleNotFoundException
  */
 public static function load($module, $path = null)
 {
     if (is_array($module)) {
         $result = true;
         foreach ($module as $mod => $path) {
             if (is_numeric($mod)) {
                 $mod = $path;
                 $path = null;
             }
             $result = $result and static::load($mod, $path);
         }
         return $result;
     }
     if (static::loaded($module)) {
         return;
     }
     // if no path is given, try to locate the module
     if ($path === null) {
         $paths = \Config::get('module_paths', array());
         if (!empty($paths)) {
             foreach ($paths as $modpath) {
                 if (is_dir($path = $modpath . strtolower($module) . DS)) {
                     break;
                 }
             }
         }
     } else {
         // make sure it's terminated properly
         $path = rtrim($path, DS) . DS;
     }
     // make sure the path exists
     if (!is_dir($path)) {
         throw new \ModuleNotFoundException("Module '{$module}' could not be found at '" . \Fuel::clean_path($path) . "'");
     }
     // determine the module namespace
     $ns = '\\' . ucfirst($module);
     // add the namespace to the autoloader
     \Autoloader::add_namespaces(array($ns => $path . 'classes' . DS), true);
     static::$modules[$module] = $path;
     return true;
 }
开发者ID:SainsburysTests,项目名称:sainsburys,代码行数:50,代码来源:module.php

示例8: run

	public static function run()
	{
		$writable_paths = array(
			APPPATH . 'cache',
			APPPATH . 'logs',
			APPPATH . 'tmp'
		);

		foreach ($writable_paths as $path)
		{
			if (@chmod($path, 0777))
			{
				\Cli::write("\t" . \Cli::color('Made writable: ' . \Fuel::clean_path($path), 'green'));
			}

			else
			{
				\Cli::write("\t" . \Cli::color('Failed to make writable: ' . \Fuel::clean_path($path), 'red'));
			}
		}
	}
开发者ID:nasumi,项目名称:fuel,代码行数:21,代码来源:install.php

示例9: migration


//.........这里部分代码省略.........
     $methods = get_class_methods(__NAMESPACE__ . '\\Generate_Migration_Actions');
     // For empty migrations that dont have actions
     $migration = array('', '');
     // Loop through the actions and act on a matching action appropriately
     foreach ($methods as $method_name) {
         // If the miration name starts with the name of the action method
         if (substr($migration_name, 0, strlen($method_name)) === $method_name) {
             /**
              *	Create an array of the subject the migration is about
              *
              *	- In a migration named 'create_users' the subject is 'users' since thats what we want to create
              *		So it would be the second object in the array
              *			array(false, 'users')
              *
              *	- In a migration named 'add_name_to_users' the object is 'name' and the subject is 'users'.
              *		So again 'users' would be the second object, but 'name' would be the first
              *			array('name', 'users')
              *
              */
             $subjects = array(false, false);
             $matches = explode('_', str_replace($method_name . '_', '', $migration_name));
             if (count($matches) == 1) {
                 $subjects = array(false, $matches[0]);
             } elseif (count($matches) == 3 and $matches[1] == 'to') {
                 $subjects = array($matches[0], $matches[2]);
             } elseif (count($matches) !== 0) {
                 $subjects = array(false, implode('_', $matches));
             } else {
                 break;
             }
             // We always pass in fields to a migration, so lets sort them out here.
             $fields = array();
             foreach ($args as $field) {
                 $field_array = array();
                 // Each paramater for a field is seperated by the : character
                 $parts = explode(":", $field);
                 // We must have the 'name:type' if nothing else!
                 if (count($parts) >= 2) {
                     $field_array['name'] = array_shift($parts);
                     foreach ($parts as $part_i => $part) {
                         preg_match('/([a-z0-9_-]+)(?:\\[([a-z0-9]+)\\])?/i', $part, $part_matches);
                         array_shift($part_matches);
                         if (count($part_matches) < 1) {
                             // Move onto the next part, something is wrong here...
                             continue;
                         }
                         $option_name = '';
                         // This is the name of the option to be passed to the action in a field
                         $option = $part_matches;
                         // The first option always has to be the field type
                         if ($part_i == 0) {
                             $option_name = 'type';
                             $type = $option[0];
                             if ($type === 'string') {
                                 $type = 'varchar';
                             } else {
                                 if ($type === 'integer') {
                                     $type = 'int';
                                 }
                             }
                             if (!in_array($type, array('text', 'blob', 'datetime', 'date', 'timestamp', 'time'))) {
                                 if (!isset($option[1]) || $option[1] == NULL) {
                                     if (isset(self::$_default_constraints[$type])) {
                                         $field_array['constraint'] = self::$_default_constraints[$type];
                                     }
                                 } else {
                                     $field_array['constraint'] = (int) $option[1];
                                 }
                             }
                             $option = $type;
                         } else {
                             // This allows you to put any number of :option or :option[val] into your field and these will...
                             // ... always be passed through to the action making it really easy to add extra options for a field
                             $option_name = array_shift($option);
                             if (count($option) > 0) {
                                 $option = $option[0];
                             } else {
                                 $option = true;
                             }
                         }
                         $field_array[$option_name] = $option;
                     }
                     $fields[] = $field_array;
                 } else {
                     // Invalid field passed in
                     continue;
                 }
             }
             // Call the magic action which returns an array($up, $down) for the migration
             \Cli::write("\tBuilding magic migration:" . $method_name);
             $migration = call_user_func(__NAMESPACE__ . "\\Generate_Migration_Actions::{$method_name}", $subjects, $fields);
         } else {
             // No magic action for this migration...
         }
     }
     // Build the migration
     if ($filepath = static::_build_migration($migration_name, $migration[0], $migration[1])) {
         \Cli::write("\tCreated migration: " . \Fuel::clean_path($filepath), 'green');
     }
 }
开发者ID:hymns,项目名称:fuel,代码行数:101,代码来源:generate.php

示例10: query

 public function query($type, $sql, $as_object)
 {
     // Make sure the database is connected
     if ($this->_connection) {
         // Make sure the connection is still alive
         if (!$this->_connection->ping()) {
             throw new \Database_Exception($this->_connection->error . ' [ ' . $sql . ' ]', $this->_connection->errno);
         }
     } else {
         $this->connect();
     }
     if (!empty($this->_config['profiling'])) {
         // Get the paths defined in config
         $paths = \Config::get('profiling_paths');
         // Storage for the trace information
         $stacktrace = array();
         // Get the execution trace of this query
         $include = false;
         foreach (debug_backtrace() as $index => $page) {
             // Skip first entry and entries without a filename
             if ($index > 0 and empty($page['file']) === false) {
                 // Checks to see what paths you want backtrace
                 foreach ($paths as $index => $path) {
                     if (strpos($page['file'], $path) !== false) {
                         $include = true;
                         break;
                     }
                 }
                 // Only log if no paths we defined, or we have a path match
                 if ($include or empty($paths)) {
                     $stacktrace[] = array('file' => Fuel::clean_path($page['file']), 'line' => $page['line']);
                 }
             }
         }
         $benchmark = \Profiler::start("Database ({$this->_instance})", $sql, $stacktrace);
     }
     if (!empty($this->_config['connection']['persistent']) and $this->_config['connection']['database'] !== static::$_current_databases[$this->_connection_id]) {
         // Select database on persistent connections
         $this->_select_db($this->_config['connection']['database']);
     }
     // Execute the query
     if (($result = $this->_connection->query($sql)) === false) {
         if (isset($benchmark)) {
             // This benchmark is worthless
             \Profiler::delete($benchmark);
         }
         throw new \Database_Exception($this->_connection->error . ' [ ' . $sql . ' ]', $this->_connection->errno);
     }
     // check for multiresults, we don't support those at the moment
     while ($this->_connection->more_results() and $this->_connection->next_result()) {
         if ($more_result = $this->_connection->use_result()) {
             throw new \Database_Exception('The MySQLi driver does not support multiple resultsets', 0);
         }
     }
     if (isset($benchmark)) {
         \Profiler::stop($benchmark);
     }
     // Set the last query
     $this->last_query = $sql;
     if ($type === \DB::SELECT) {
         // Return an iterator of results
         return new \Database_MySQLi_Result($result, $sql, $as_object);
     } elseif ($type === \DB::INSERT) {
         // Return a list of insert id and rows created
         return array($this->_connection->insert_id, $this->_connection->affected_rows);
     } else {
         // Return the number of rows affected
         return $this->_connection->affected_rows;
     }
 }
开发者ID:vienbk91,项目名称:fuelphp17,代码行数:70,代码来源:connection.php

示例11: prepare_exception

 protected static function prepare_exception(\Exception $e, $fatal = true)
 {
     $data = array();
     $data['type'] = get_class($e);
     $data['severity'] = $e->getCode();
     $data['message'] = $e->getMessage();
     $data['filepath'] = $e->getFile();
     $data['error_line'] = $e->getLine();
     $data['backtrace'] = $e->getTrace();
     $data['severity'] = !isset(static::$levels[$data['severity']]) ? $data['severity'] : static::$levels[$data['severity']];
     foreach ($data['backtrace'] as $key => $trace) {
         if (!isset($trace['file'])) {
             unset($data['backtrace'][$key]);
         } elseif ($trace['file'] == COREPATH . 'classes/error.php') {
             unset($data['backtrace'][$key]);
         }
     }
     $data['debug_lines'] = \Debug::file_lines($data['filepath'], $data['error_line'], $fatal);
     $data['orig_filepath'] = $data['filepath'];
     $data['filepath'] = \Fuel::clean_path($data['filepath']);
     $data['filepath'] = str_replace("\\", "/", $data['filepath']);
     return $data;
 }
开发者ID:bryanheo,项目名称:FuelPHP-Auth-AJAX,代码行数:23,代码来源:error.php

示例12: run_validation

 /**
  * Run the environment validation
  */
 protected static function run_validation()
 {
     // storage for collected errors
     $errors = array();
     // validate the auth configuration file
     if (!is_file($file = APPPATH . 'config' . DS . 'auth.php')) {
         $errors[] = \Fuel::clean_path($file) . ' does not exist.';
     } else {
         \Config::load('auth', true);
         if (!($driver = \Config::get('auth.driver', false))) {
             $errors[] = \Fuel::clean_path($file) . ' does not define an auth driver.';
         } elseif ($driver != 'Ormauth') {
             $errors[] = \Fuel::clean_path($file) . ' is not configured to use the Ormauth driver.';
         }
     }
     // validate the simpleauth configuration file
     if (!is_file($file = APPPATH . 'config' . DS . 'simpleauth.php')) {
         $errors[] = \Fuel::clean_path($file) . ' does not exist.';
     } else {
         \Config::load('simpleauth', true);
         if (!($table = \Config::get('simpleauth.table_name', false))) {
             $errors[] = \Fuel::clean_path($file) . ' does not define a user table.';
         } elseif (!\DBUtil::table_exists($table)) {
             $errors[] = \Fuel::clean_path($file) . ' defines a table that does not exist.';
         } else {
             // store the table name for future use
             static::$data['simpleauth_table'] = $table;
         }
     }
     // validate the ormauth configuration file
     if (!is_file($file = APPPATH . 'config' . DS . 'ormauth.php')) {
         $errors[] = \Fuel::clean_path($file) . ' does not exist.';
     } else {
         $config = \Config::load('ormauth', true);
         if (!($table = \Config::get('ormauth.table_name', false))) {
             $errors[] = \Fuel::clean_path($file) . ' does not define a user table.';
         } elseif (!\DBUtil::table_exists($table)) {
             $errors[] = \Fuel::clean_path($file) . ' defines a table that does not exist.';
         } else {
             // store the table name for future use
             static::$data['ormauth_table'] = $table;
         }
         if (!($cache_prefix = \Config::get('ormauth.cache_prefix', false)) or empty($cache_prefix)) {
             $errors[] = \Fuel::clean_path($file) . ' does not define a cache_prefix.';
         } else {
             // store the cache prefix for future use
             static::$data['cache_prefix'] = $cache_prefix;
         }
     }
     // check if all migrations have run, and the migration system is consistent
     $migrations = \Config::load('migrations', true);
     if (!isset($migrations['version']['package']['auth'][6])) {
         $errors[] = 'Auth database migrations haven\'t run (succesfully).';
     } else {
         $result = \DB::select('*')->from($migrations['table'])->where('type', '=', 'package')->where('name', '=', 'auth')->execute();
         if (count($result) < 7) {
             $errors[] = 'Auth database migrations haven\'t run (succesfully).';
             $errors[] = 'There is a discrepancy between your migration configuration file and the migration table.';
         }
     }
     // check the fields of the users table
     $usertable = array('id' => array('type' => 'int', 'constraint' => 11, 'auto_increment' => true), 'username' => array('type' => 'varchar', 'constraint' => 50, 'after' => 'id'), 'password' => array('type' => 'varchar', 'constraint' => 255, 'after' => 'username'), 'group_id' => array('type' => 'int', 'constraint' => 11, 'default' => 1, 'after' => 'password'), 'email' => array('type' => 'varchar', 'constraint' => 255, 'after' => 'group_id'), 'last_login' => array('type' => 'varchar', 'constraint' => 25, 'after' => 'email'), 'previous_login' => array('type' => 'varchar', 'constraint' => 25, 'default' => 0, 'after' => 'last_login'), 'login_hash' => array('type' => 'varchar', 'constraint' => 255, 'after' => 'previous_login'), 'user_id' => array('type' => 'int', 'constraint' => 11, 'default' => 0, 'after' => 'login_hash'), 'created_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0, 'after' => 'user_id'), 'updated_at' => array('type' => 'int', 'constraint' => 11, 'default' => 0, 'after' => 'created_at'));
     foreach ($usertable as $field => $value) {
         if (\DBUtil::field_exists(static::$data['ormauth_table'], $field)) {
             unset($usertable[$field]);
         }
     }
     if (!empty($usertable)) {
         $errors[] = 'User table "' . static::$data['ormauth_table'] . '" is missing the field(s): ' . implode(', ', array_keys($usertable));
     }
     // process the results of the validation
     if ($errors) {
         // display all errors
         \Cli::write('You environment did not validate:', 'light_red');
         foreach ($errors as $error) {
             \Cli::write('* ' . $error);
         }
         return false;
     }
     // inform the user we're good to go
     \Cli::write('Environment validated', 'light_green');
     return true;
 }
开发者ID:socialskeptic,项目名称:sainsburys,代码行数:86,代码来源:simple2orm.php

示例13: migration

 public function migration($args)
 {
     $migration_name = strtolower(array_shift($args));
     // Starts with create, so lets create a table
     if (strpos($migration_name, 'create_') === 0) {
         $mode = 'create_table';
         $table = str_replace('create_', '', $migration_name);
     } else {
         if (strpos($migration_name, 'add_') === 0) {
             $mode = 'add_fields';
             preg_match('/add_[a-z0-9_]+_to_([a-z0-9_]+)/i', $migration_name, $matches);
             $table = $matches[1];
         } else {
             if (strpos($migration_name, 'remove_') === 0) {
                 $mode = 'remove_field';
                 preg_match('/remove_([a-z0-9_])+_from_([a-z0-9_]+)/i', $migration_name, $matches);
                 $remove_field = $matches[1];
                 $table = $matches[2];
             } else {
                 if (strpos($migration_name, 'drop_') === 0) {
                     $mode = 'drop_table';
                     $table = str_replace('drop_', '', $migration_name);
                 }
             }
         }
     }
     unset($matches);
     // Now that we know that, lets build the migration
     if ($filepath = static::_build_migration($migration_name, $mode, $table, $args)) {
         \Cli::write('Created migration: ' . \Fuel::clean_path($filepath));
     }
 }
开发者ID:huglester,项目名称:fuel-uploadify,代码行数:32,代码来源:generate.php

示例14: query

 /**
  * Query the database
  *
  * @param integer $type
  * @param string  $sql
  * @param mixed   $as_object
  *
  * @return mixed
  *
  * @throws \Database_Exception
  */
 public function query($type, $sql, $as_object)
 {
     // Make sure the database is connected
     $this->_connection or $this->connect();
     if (!empty($this->_config['profiling'])) {
         // Get the paths defined in config
         $paths = \Config::get('profiling_paths');
         // Storage for the trace information
         $stacktrace = array();
         // Get the execution trace of this query
         $include = false;
         foreach (debug_backtrace() as $index => $page) {
             // Skip first entry and entries without a filename
             if ($index > 0 and empty($page['file']) === false) {
                 // Checks to see what paths you want backtrace
                 foreach ($paths as $index => $path) {
                     if (strpos($page['file'], $path) !== false) {
                         $include = true;
                         break;
                     }
                 }
                 // Only log if no paths we defined, or we have a path match
                 if ($include or empty($paths)) {
                     $stacktrace[] = array('file' => \Fuel::clean_path($page['file']), 'line' => $page['line']);
                 }
             }
         }
         $benchmark = \Profiler::start($this->_instance, $sql, $stacktrace);
     }
     // run the query. if the connection is lost, try 3 times to reconnect
     $attempts = 3;
     do {
         try {
             // try to run the query
             $result = $this->_connection->query($sql);
             break;
         } catch (\Exception $e) {
             // if failed and we have attempts left
             if ($attempts > 0) {
                 // try reconnecting if it was a MySQL disconnected error
                 if (strpos($e->getMessage(), '2006 MySQL') !== false) {
                     $this->disconnect();
                     $this->connect();
                 } else {
                     // other database error, cleanup the profiler
                     isset($benchmark) and \Profiler::delete($benchmark);
                     // and convert the exception in a database exception
                     if (!is_numeric($error_code = $e->getCode())) {
                         if ($this->_connection) {
                             $error_code = $this->_connection->errorinfo();
                             $error_code = $error_code[1];
                         } else {
                             $error_code = 0;
                         }
                     }
                     throw new \Database_Exception($e->getMessage() . ' with query: "' . $sql . '"', $error_code, $e);
                 }
             } else {
                 // and convert the exception in a database exception
                 if (!is_numeric($error_code = $e->getCode())) {
                     if ($this->_connection) {
                         $error_code = $this->_connection->errorinfo();
                         $error_code = $error_code[1];
                     } else {
                         $error_code = 0;
                     }
                 }
                 throw new \Database_Exception($e->getMessage() . ' with query: "' . $sql . '"', $error_code, $e);
             }
         }
     } while ($attempts-- > 0);
     if (isset($benchmark)) {
         \Profiler::stop($benchmark);
     }
     // Set the last query
     $this->last_query = $sql;
     if ($type === \DB::SELECT) {
         // Convert the result into an array, as PDOStatement::rowCount is not reliable
         if ($as_object === false) {
             $result = $result->fetchAll(\PDO::FETCH_ASSOC);
         } elseif (is_string($as_object)) {
             $result = $result->fetchAll(\PDO::FETCH_CLASS, $as_object);
         } else {
             $result = $result->fetchAll(\PDO::FETCH_CLASS, 'stdClass');
         }
         // Return an iterator of results
         return new \Database_Result_Cached($result, $sql, $as_object);
     } elseif ($type === \DB::INSERT) {
         // Return a list of insert id and rows created
//.........这里部分代码省略.........
开发者ID:SainsburysTests,项目名称:sainsburys,代码行数:101,代码来源:connection.php

示例15: set_filename

 /**
  * Sets the view filename.
  *
  *     $view->set_filename($file);
  *
  * @param   string  view filename
  * @return  View
  * @throws  FuelException
  */
 public function set_filename($file)
 {
     // strip the extension from it
     $pathinfo = pathinfo($file);
     if (!empty($pathinfo['extension'])) {
         $this->extension = $pathinfo['extension'];
         $file = substr($file, 0, strlen($this->extension) * -1 - 1);
     }
     // set find_file's one-time-only search paths
     \Finder::instance()->flash($this->request_paths);
     // locate the view file
     if (($path = \Finder::search('views', $file, '.' . $this->extension, false, false)) === false) {
         throw new \FuelException('The requested view could not be found: ' . \Fuel::clean_path($file) . '.' . $this->extension);
     }
     // Store the file path locally
     $this->file_name = $path;
     return $this;
 }
开发者ID:socialskeptic,项目名称:sainsburys,代码行数:27,代码来源:view.php


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