From 193f67b570576f3746faf743b78ea5fd51596176 Mon Sep 17 00:00:00 2001 From: Juan Date: Tue, 8 May 2018 17:09:44 +0200 Subject: [PATCH] Git hook, dependencies fixed, linting, bugfixes --- db/connection.php | 48 +++++++++++++++++++++++------------------------ db/exception.php | 1 - db/my.cnf | 0 debian/changelog | 2 +- debian/compat | 0 debian/control | 4 ++-- debian/copyright | 2 +- debian/install | 0 deploy | 5 +++++ env.php | 1 - lib/app.php | 27 +++++++++++++------------- lib/log.php | 1 - lib/method.php | 10 +++++----- vn-autoload.php | 1 - 14 files changed, 51 insertions(+), 51 deletions(-) mode change 100644 => 100755 db/exception.php mode change 100644 => 100755 db/my.cnf mode change 100644 => 100755 debian/changelog mode change 100644 => 100755 debian/compat mode change 100644 => 100755 debian/control mode change 100644 => 100755 debian/copyright mode change 100644 => 100755 debian/install create mode 100755 deploy mode change 100644 => 100755 env.php mode change 100644 => 100755 lib/app.php mode change 100644 => 100755 lib/log.php mode change 100644 => 100755 lib/method.php mode change 100644 => 100755 vn-autoload.php diff --git a/db/connection.php b/db/connection.php index ded04fe..34c6854 100755 --- a/db/connection.php +++ b/db/connection.php @@ -23,12 +23,11 @@ class Connection * @param string $name The default schema name * * @return boolean %TRUE on success, %FALSE otherwise - **/ + */ function open ($host, $user, $pass, $name, $port = NULL) { $conn = $this->initHandler (); $conn->options (MYSQLI_OPT_LOCAL_INFILE, TRUE); - $conn->options (MYSQLI_READ_DEFAULT_FILE, __DIR__.'/my.cnf'); $conn->real_connect ($host, $user, $pass, $name, $port); if (mysqli_connect_errno ()) @@ -45,7 +44,7 @@ class Connection /** * Closes the current connection, if it's closed does nothing. - **/ + */ function close () { if ($this->isOpen) @@ -61,7 +60,7 @@ class Connection * Initializes the internal database connection handler. * * @return Objetct The connection handler - **/ + */ function initHandler () { if (!$this->conn) @@ -76,7 +75,7 @@ class Connection * the Connection class methods. * * @return Objetct The connection handler - **/ + */ function getHandler () { return $this->conn; @@ -87,7 +86,7 @@ class Connection * * @param string $schema The schema name * @return boolean %TRUE if success, %FALSE otherwise - **/ + */ function selectDb ($dbName) { return $this->conn->select_db ($dbName); @@ -100,7 +99,7 @@ class Connection * @param mixed[] $params The query parameters * * @return mixed The value or %NULL if error - **/ + */ function query ($query, $params = NULL) { $result = $this->conn->query ($this->render ($query, $params)); @@ -118,7 +117,7 @@ class Connection * Checks whether the connection is open. * * @return boolean %TRUE if connection is open, %FALSE otherwise - **/ + */ function isOpen () { return $this->isOpen; @@ -130,7 +129,7 @@ class Connection * @param resource $result The database result * * @return mixed[] An associative array with the first row, %NULL if error - **/ + */ function getRowFromResult ($result) { if ($result) @@ -149,7 +148,7 @@ class Connection * @param resource $result The database result * * @return object An object with the first row, %NULL if error - **/ + */ function getObjectFromResult ($result) { if ($result) @@ -168,7 +167,7 @@ class Connection * @param resource $result The database result * * @return mixed The value or %NULL if error - **/ + */ function getValueFromResult ($result) { $value = NULL; @@ -193,7 +192,7 @@ class Connection * @param mixed[] $params The query parameters * * @return mixed[] An associative array with the first row, %NULL if error - **/ + */ function getRow ($query, $params = NULL) { $result = $this->query ($query, $params); @@ -207,7 +206,7 @@ class Connection * @param mixed[] $params The query parameters * * @return object An object with the first row, %NULL if error - **/ + */ function getObject ($query, $params = NULL) { $result = $this->query ($query, $params); @@ -221,7 +220,7 @@ class Connection * @param mixed[] $params The query parameters * * @return mixed The value or %NULL if error - **/ + */ function getValue ($query, $params = NULL) { $result = $this->query ($query, $params); @@ -235,7 +234,7 @@ class Connection * @param mixed[] $params The query parameters * * @return mixed The query string - **/ + */ function loadFromFile ($file, $params = NULL) { $query = file_get_contents ($file .'.sql'); @@ -253,7 +252,7 @@ class Connection * @param mixed[] $params The query parameters * * @return mixed The value or %NULL if error - **/ + */ function queryFromFile ($file, $params = NULL) { $query = $this->loadFromFile ($file, $params); @@ -271,7 +270,7 @@ class Connection * @param mixed[] $params The query parameters * * @return mixed[] An associative array with the first row, %NULL if error - **/ + */ function getRowFromFile ($file, $params = NULL) { $result = $this->queryFromFile ($file, $params); @@ -285,7 +284,7 @@ class Connection * @param mixed[] $params The query parameters * * @return mixed The value or %NULL if error - **/ + */ function getValueFromFile ($file, $params = NULL) { $result = $this->queryFromFile ($file, $params); @@ -299,7 +298,7 @@ class Connection * @param mixed[] $params The query parameters * * @return mixed The value or %NULL if error - **/ + */ function multiQuery ($query, $params = NULL) { $success = $this->conn->multi_query ($this->render ($query, $params)); @@ -316,7 +315,7 @@ class Connection * @param string $query The SQL query * * @return mixed The statement object or %FALSE if an error occurred - **/ + */ function prepare ($query) { return $this->conn->prepare ($query); @@ -347,7 +346,7 @@ class Connection /** * Check if there has been an error in the last query or multiquery, * throwing a @Exception exception if any. - **/ + */ function checkError () { if ($this->conn->errno) @@ -358,7 +357,7 @@ class Connection * Check if there have been warnings in the last query. * * @return boolean %TRUE if there have been warnings %FALSE otherwise - **/ + */ function checkWarnings () { return $this->conn->warning_count > 0; @@ -371,7 +370,7 @@ class Connection * @param mixed[] $paramsMap The query parameters * * @return string The rendered SQL string - **/ + */ function render ($query, $paramsMap = NULL) { if (isset ($paramsMap) && is_array ($paramsMap) && count ($paramsMap) > 0) @@ -406,7 +405,7 @@ class Connection * @param mixed $value The value * * @return string The SQL value - **/ + */ function renderValue ($value) { if ($value !== NULL) @@ -429,4 +428,3 @@ class Connection return 'NULL'; } } - diff --git a/db/exception.php b/db/exception.php old mode 100644 new mode 100755 index ca8bedd..c72ad4b --- a/db/exception.php +++ b/db/exception.php @@ -16,4 +16,3 @@ class Exception extends \Exception parent::__construct ($message, $code); } } - diff --git a/db/my.cnf b/db/my.cnf old mode 100644 new mode 100755 diff --git a/debian/changelog b/debian/changelog old mode 100644 new mode 100755 index a90d00e..63d9849 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -php-vn-lib (2.1.2) stable; urgency=low +php-vn-lib (2.1.3) stable; urgency=low * Initial Release. diff --git a/debian/compat b/debian/compat old mode 100644 new mode 100755 diff --git a/debian/control b/debian/control old mode 100644 new mode 100755 index 9bce98a..fad6218 --- a/debian/control +++ b/debian/control @@ -5,11 +5,11 @@ Build-Depends: build-essential, debhelper Standards-Version: 3.9.3 Section: misc Homepage: http://www.verdnatura.es -Vcs-Git: git://www.verdnatura.es/var/git/php-vn-lib +Vcs-Git: https://gitverdnatura.es/php-vn-lib Package: php-vn-lib Architecture: all -Depends: php5-mysql +Depends: php-mysql Section: misc Priority: optional Description: PHP libraries diff --git a/debian/copyright b/debian/copyright old mode 100644 new mode 100755 index 6f2b3d9..ae9c7e6 --- a/debian/copyright +++ b/debian/copyright @@ -1,6 +1,6 @@ Format: http://dep.debian.net/deps/dep5 Name: php-vn-lib -Source: git://www.verdnatura.es/var/git/php-vn-lib +Source: https://git.verdnatura.es/php-vn-lib Files: * Copyright: 2011-2015 Juan Ferrer Toribio diff --git a/debian/install b/debian/install old mode 100644 new mode 100755 diff --git a/deploy b/deploy new file mode 100755 index 0000000..7dae519 --- /dev/null +++ b/deploy @@ -0,0 +1,5 @@ +#!/bin/bash +set -e + +vn-debuild +vn-deploy root@www1.static root@www2.static diff --git a/env.php b/env.php old mode 100644 new mode 100755 index 067e1e7..5b0377e --- a/env.php +++ b/env.php @@ -5,4 +5,3 @@ set_include_path (__DIR__.PATH_SEPARATOR.get_include_path ()); $vnAutoloadMap = []; $vnAutoloadMap['vn/lib'] = __DIR__.'/lib'; $vnAutoloadMap['vn/db'] = __DIR__.'/db'; - diff --git a/lib/app.php b/lib/app.php old mode 100644 new mode 100755 index 6e51f9a..172b096 --- a/lib/app.php +++ b/lib/app.php @@ -20,7 +20,7 @@ if (!defined ('_DATA_DIR')) /** * Base class for applications. - **/ + */ class App { protected $name; @@ -32,7 +32,7 @@ class App * Creates a new application object. * * @param name string The application name - **/ + */ function __construct ($name, $methodDir = NULL) { $this->name = $name; @@ -43,7 +43,7 @@ class App * Returns the name of the application. * * @return The application name - **/ + */ function getName () { return $this->name; @@ -53,7 +53,7 @@ class App * Returns the configuration object. * * @return The config object - **/ + */ function getConf () { return $this->conf; @@ -62,7 +62,7 @@ class App /** * Initializes Application. Should be the first called function in any * application that uses this class. - **/ + */ function init () { ini_set ('log_errors', TRUE); @@ -77,7 +77,7 @@ class App /** * Deinitializes the Application. When init method is called, this * function is called automatically at the end of the script. - **/ + */ function deinit () { if ($this->sysConn) @@ -89,13 +89,15 @@ class App /** * Gets the configuration file name. - **/ + */ function getConfigFile () { $configDir = _CONFIG_DIR .'/'. $this->name; $customFile = "$configDir/config.my.php"; - if (file_exists ($customFile)) + if (file_exists ('config.php')) + return 'config.php'; + else if (file_exists ($customFile)) return $customFile; else return "$configDir/config.php"; @@ -104,7 +106,7 @@ class App /** * Creates a new connection object using the configuration parameters and * the passed user and password. - **/ + */ function createConnection ($user, $password, $persistent = FALSE) { $dbConf = $this->conf['db']; @@ -129,7 +131,7 @@ class App * Opens the system database connection. * * @return Vn\Db\Conn The connection - **/ + */ function getSysConn () { if (!$this->sysConn) @@ -144,12 +146,12 @@ class App /** * Starts the application. Should be implemented by child classes. - **/ + */ function run () {} /** * Runs a method. - **/ + */ function loadMethod ($methodUri = NULL, $checkClass = NULL, $baseDir = NULL) { // XXX: Partially implemented @@ -190,4 +192,3 @@ class App return new $className ($this); } } - diff --git a/lib/log.php b/lib/log.php old mode 100644 new mode 100755 index a4181cd..e0ddf3c --- a/lib/log.php +++ b/lib/log.php @@ -71,4 +71,3 @@ class Log self::$count = 0; } } - diff --git a/lib/method.php b/lib/method.php old mode 100644 new mode 100755 index 2d073ed..c1cc2f7 --- a/lib/method.php +++ b/lib/method.php @@ -4,7 +4,7 @@ namespace Vn\Lib; /** * Base class for rest methods. - **/ + */ abstract class Method { protected $app; @@ -14,7 +14,7 @@ abstract class Method * Initializes the method. * * @param app Lib\App The application - **/ + */ function __construct ($app) { $this->app = $app; @@ -25,14 +25,14 @@ abstract class Method * * @param {Db\Conn} $db The main database connection * @return mixed The result of the method - **/ + */ abstract function run ($db); /** * Returns the system database connection. * * return {Db\Conn} The database connection - **/ + */ function getSysConn () { return $this->app->getSysConn (); @@ -45,7 +45,7 @@ abstract class Method * @param {string} $map The map to check * @param {array} $params The list of keys to check * @return {boolean} %TRUE if all key are defined, %FALSE otherwise - **/ + */ function checkParams ($map, $params) { if (!isset ($map)) diff --git a/vn-autoload.php b/vn-autoload.php old mode 100644 new mode 100755 index cfc696a..6e492f6 --- a/vn-autoload.php +++ b/vn-autoload.php @@ -37,4 +37,3 @@ spl_autoload_register (function ($className) if (file_exists ($classPath)) require_once $classPath; }); -