Git hook, dependencies fixed, linting, bugfixes
This commit is contained in:
parent
363f1718be
commit
193f67b570
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,4 +16,3 @@ class Exception extends \Exception
|
|||
parent::__construct ($message, $code);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
php-vn-lib (2.1.2) stable; urgency=low
|
||||
php-vn-lib (2.1.3) stable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <juan@verdnatura.es>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
vn-debuild
|
||||
vn-deploy root@www1.static root@www2.static
|
|
@ -5,4 +5,3 @@ set_include_path (__DIR__.PATH_SEPARATOR.get_include_path ());
|
|||
$vnAutoloadMap = [];
|
||||
$vnAutoloadMap['vn/lib'] = __DIR__.'/lib';
|
||||
$vnAutoloadMap['vn/db'] = __DIR__.'/db';
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,4 +71,3 @@ class Log
|
|||
self::$count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -37,4 +37,3 @@ spl_autoload_register (function ($className)
|
|||
if (file_exists ($classPath))
|
||||
require_once $classPath;
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue