@@ -36,91 +36,91 @@ |
||
| 36 | 36 | * @method array fetchAll(integer $fetchMode = null); |
| 37 | 37 | */ |
| 38 | 38 | class OC_DB_StatementWrapper { |
| 39 | - /** |
|
| 40 | - * @var \Doctrine\DBAL\Driver\Statement |
|
| 41 | - */ |
|
| 42 | - private $statement = null; |
|
| 43 | - private $isManipulation = false; |
|
| 44 | - private $lastArguments = array(); |
|
| 39 | + /** |
|
| 40 | + * @var \Doctrine\DBAL\Driver\Statement |
|
| 41 | + */ |
|
| 42 | + private $statement = null; |
|
| 43 | + private $isManipulation = false; |
|
| 44 | + private $lastArguments = array(); |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @param boolean $isManipulation |
|
| 48 | - */ |
|
| 49 | - public function __construct($statement, $isManipulation) { |
|
| 50 | - $this->statement = $statement; |
|
| 51 | - $this->isManipulation = $isManipulation; |
|
| 52 | - } |
|
| 46 | + /** |
|
| 47 | + * @param boolean $isManipulation |
|
| 48 | + */ |
|
| 49 | + public function __construct($statement, $isManipulation) { |
|
| 50 | + $this->statement = $statement; |
|
| 51 | + $this->isManipulation = $isManipulation; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * pass all other function directly to the \Doctrine\DBAL\Driver\Statement |
|
| 56 | - */ |
|
| 57 | - public function __call($name,$arguments) { |
|
| 58 | - return call_user_func_array(array($this->statement,$name), $arguments); |
|
| 59 | - } |
|
| 54 | + /** |
|
| 55 | + * pass all other function directly to the \Doctrine\DBAL\Driver\Statement |
|
| 56 | + */ |
|
| 57 | + public function __call($name,$arguments) { |
|
| 58 | + return call_user_func_array(array($this->statement,$name), $arguments); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * make execute return the result instead of a bool |
|
| 63 | - * |
|
| 64 | - * @param array $input |
|
| 65 | - * @return \OC_DB_StatementWrapper|int |
|
| 66 | - */ |
|
| 67 | - public function execute($input=array()) { |
|
| 68 | - if(\OC::$server->getSystemConfig()->getValue( "log_query", false)) { |
|
| 69 | - $backTrace = debug_backtrace(); |
|
| 70 | - $class = $backTrace[1]['class'] . ':' . $backTrace[1]['function']; |
|
| 71 | - $file = substr($backTrace[0]['file'], strlen(\OC::$SERVERROOT)) . ':' . $backTrace[0]['line']; |
|
| 72 | - $params_str = str_replace("\n", " ", var_export($input, true)); |
|
| 73 | - \OCP\Util::writeLog('core', "DB execute with arguments : $params_str in $class; $file", \OCP\Util::DEBUG); |
|
| 74 | - } |
|
| 75 | - $this->lastArguments = $input; |
|
| 76 | - if (count($input) > 0) { |
|
| 77 | - $result = $this->statement->execute($input); |
|
| 78 | - } else { |
|
| 79 | - $result = $this->statement->execute(); |
|
| 80 | - } |
|
| 61 | + /** |
|
| 62 | + * make execute return the result instead of a bool |
|
| 63 | + * |
|
| 64 | + * @param array $input |
|
| 65 | + * @return \OC_DB_StatementWrapper|int |
|
| 66 | + */ |
|
| 67 | + public function execute($input=array()) { |
|
| 68 | + if(\OC::$server->getSystemConfig()->getValue( "log_query", false)) { |
|
| 69 | + $backTrace = debug_backtrace(); |
|
| 70 | + $class = $backTrace[1]['class'] . ':' . $backTrace[1]['function']; |
|
| 71 | + $file = substr($backTrace[0]['file'], strlen(\OC::$SERVERROOT)) . ':' . $backTrace[0]['line']; |
|
| 72 | + $params_str = str_replace("\n", " ", var_export($input, true)); |
|
| 73 | + \OCP\Util::writeLog('core', "DB execute with arguments : $params_str in $class; $file", \OCP\Util::DEBUG); |
|
| 74 | + } |
|
| 75 | + $this->lastArguments = $input; |
|
| 76 | + if (count($input) > 0) { |
|
| 77 | + $result = $this->statement->execute($input); |
|
| 78 | + } else { |
|
| 79 | + $result = $this->statement->execute(); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - if ($result === false) { |
|
| 83 | - return false; |
|
| 84 | - } |
|
| 85 | - if ($this->isManipulation) { |
|
| 86 | - $count = $this->statement->rowCount(); |
|
| 87 | - return $count; |
|
| 88 | - } else { |
|
| 89 | - return $this; |
|
| 90 | - } |
|
| 91 | - } |
|
| 82 | + if ($result === false) { |
|
| 83 | + return false; |
|
| 84 | + } |
|
| 85 | + if ($this->isManipulation) { |
|
| 86 | + $count = $this->statement->rowCount(); |
|
| 87 | + return $count; |
|
| 88 | + } else { |
|
| 89 | + return $this; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * provide an alias for fetch |
|
| 95 | - * |
|
| 96 | - * @return mixed |
|
| 97 | - */ |
|
| 98 | - public function fetchRow() { |
|
| 99 | - return $this->statement->fetch(); |
|
| 100 | - } |
|
| 93 | + /** |
|
| 94 | + * provide an alias for fetch |
|
| 95 | + * |
|
| 96 | + * @return mixed |
|
| 97 | + */ |
|
| 98 | + public function fetchRow() { |
|
| 99 | + return $this->statement->fetch(); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Provide a simple fetchOne. |
|
| 104 | - * |
|
| 105 | - * fetch single column from the next row |
|
| 106 | - * @param int $column the column number to fetch |
|
| 107 | - * @return string |
|
| 108 | - */ |
|
| 109 | - public function fetchOne($column = 0) { |
|
| 110 | - return $this->statement->fetchColumn($column); |
|
| 111 | - } |
|
| 102 | + /** |
|
| 103 | + * Provide a simple fetchOne. |
|
| 104 | + * |
|
| 105 | + * fetch single column from the next row |
|
| 106 | + * @param int $column the column number to fetch |
|
| 107 | + * @return string |
|
| 108 | + */ |
|
| 109 | + public function fetchOne($column = 0) { |
|
| 110 | + return $this->statement->fetchColumn($column); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Binds a PHP variable to a corresponding named or question mark placeholder in the |
|
| 115 | - * SQL statement that was use to prepare the statement. |
|
| 116 | - * |
|
| 117 | - * @param mixed $column Either the placeholder name or the 1-indexed placeholder index |
|
| 118 | - * @param mixed $variable The variable to bind |
|
| 119 | - * @param integer|null $type one of the PDO::PARAM_* constants |
|
| 120 | - * @param integer|null $length max length when using an OUT bind |
|
| 121 | - * @return boolean |
|
| 122 | - */ |
|
| 123 | - public function bindParam($column, &$variable, $type = null, $length = null){ |
|
| 124 | - return $this->statement->bindParam($column, $variable, $type, $length); |
|
| 125 | - } |
|
| 113 | + /** |
|
| 114 | + * Binds a PHP variable to a corresponding named or question mark placeholder in the |
|
| 115 | + * SQL statement that was use to prepare the statement. |
|
| 116 | + * |
|
| 117 | + * @param mixed $column Either the placeholder name or the 1-indexed placeholder index |
|
| 118 | + * @param mixed $variable The variable to bind |
|
| 119 | + * @param integer|null $type one of the PDO::PARAM_* constants |
|
| 120 | + * @param integer|null $length max length when using an OUT bind |
|
| 121 | + * @return boolean |
|
| 122 | + */ |
|
| 123 | + public function bindParam($column, &$variable, $type = null, $length = null){ |
|
| 124 | + return $this->statement->bindParam($column, $variable, $type, $length); |
|
| 125 | + } |
|
| 126 | 126 | } |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | /** |
| 55 | 55 | * pass all other function directly to the \Doctrine\DBAL\Driver\Statement |
| 56 | 56 | */ |
| 57 | - public function __call($name,$arguments) { |
|
| 58 | - return call_user_func_array(array($this->statement,$name), $arguments); |
|
| 57 | + public function __call($name, $arguments) { |
|
| 58 | + return call_user_func_array(array($this->statement, $name), $arguments); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | * @param array $input |
| 65 | 65 | * @return \OC_DB_StatementWrapper|int |
| 66 | 66 | */ |
| 67 | - public function execute($input=array()) { |
|
| 68 | - if(\OC::$server->getSystemConfig()->getValue( "log_query", false)) { |
|
| 67 | + public function execute($input = array()) { |
|
| 68 | + if (\OC::$server->getSystemConfig()->getValue("log_query", false)) { |
|
| 69 | 69 | $backTrace = debug_backtrace(); |
| 70 | - $class = $backTrace[1]['class'] . ':' . $backTrace[1]['function']; |
|
| 71 | - $file = substr($backTrace[0]['file'], strlen(\OC::$SERVERROOT)) . ':' . $backTrace[0]['line']; |
|
| 70 | + $class = $backTrace[1]['class'].':'.$backTrace[1]['function']; |
|
| 71 | + $file = substr($backTrace[0]['file'], strlen(\OC::$SERVERROOT)).':'.$backTrace[0]['line']; |
|
| 72 | 72 | $params_str = str_replace("\n", " ", var_export($input, true)); |
| 73 | 73 | \OCP\Util::writeLog('core', "DB execute with arguments : $params_str in $class; $file", \OCP\Util::DEBUG); |
| 74 | 74 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @param integer|null $length max length when using an OUT bind |
| 121 | 121 | * @return boolean |
| 122 | 122 | */ |
| 123 | - public function bindParam($column, &$variable, $type = null, $length = null){ |
|
| 123 | + public function bindParam($column, &$variable, $type = null, $length = null) { |
|
| 124 | 124 | return $this->statement->bindParam($column, $variable, $type, $length); |
| 125 | 125 | } |
| 126 | 126 | } |