<?php if (!session_start()) { session_start(); } define("lib_dir", "../lib_db/"); // Lib_DB directory. define("db_config_file", getcwd() . "/config/database.yml"); // Database config file.getcwd->actual dir // Funcion encargada de cargar automaticamente cualquier clase, sin include(). function __autoload($class_name) { require_once lib_dir . $class_name . '.php'; } // Recuperamos los parametros de conexion sql del archivo yml. $sql_params = yml::load_yml(db_config_file); // Los cargamos en un array global 'sql'. $GLOBALS[sql] = array(host => $sql_params[host], user => $sql_params[user], pass => $sql_params[pass], db => $sql_params[db], connect => $sql_params[connect], log => $sql_params[log], restricted => $sql_params[restricted]);
/** * Dump YAML from PHP array statically * * The dump method, when supplied with an array, will do its best * to convert the array into friendly YAML. Pretty simple. Feel free to * save the returned string as nothing.yaml and pass it around. * * Oh, and you can decide how big the indent is and what the wordwrap * for folding is. Pretty cool -- just pass in 'false' for either if * you want to use the default. * * Indent's default is 2 spaces, wordwrap's default is 40 characters. And * you can turn off wordwrap by passing in 0. * * @access public * @return string * @param array $array PHP array * @param int $indent Pass in false to use the default, which is 2 * @param int $wordwrap Pass in 0 for no wordwrap, false for default (40) */ function YAMLDump($array, $indent = false, $wordwrap = false) { $spyc = new yml(); return $spyc->dump($array, $indent, $wordwrap); }