Blame view
sources/lib/private/db/connectionwrapper.php
2.4 KB
|
31b7f2792
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
<?php
/**
* Copyright (c) 2013 Thomas Müller <deepdiver@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OC\DB;
class ConnectionWrapper implements \OCP\IDBConnection {
private $connection;
public function __construct(Connection $conn) {
$this->connection = $conn;
}
/**
* Used to the owncloud database access away
* @param string $sql the sql query with ? placeholder for params
* @param int $limit the maximum number of rows
* @param int $offset from which row we want to start
* @return \Doctrine\DBAL\Driver\Statement The prepared statement.
*/
public function prepare($sql, $limit = null, $offset = null)
{
return $this->connection->prepare($sql, $limit, $offset);
}
/**
* Used to get the id of the just inserted element
|
|
6d9380f96
|
34 35 |
* @param string $table the name of the table where we inserted the item * @return string the id of the inserted element |
|
31b7f2792
|
36 37 38 39 40 41 42 43 |
*/
public function lastInsertId($table = null)
{
return $this->connection->lastInsertId($table);
}
/**
* Insert a row if a matching row doesn't exists.
|
|
6d9380f96
|
44 45 |
* @param string $table The table name (will replace *PREFIX*) to perform the replace on. * @param array $input |
|
31b7f2792
|
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
*
* The input array if in the form:
*
* array ( 'id' => array ( 'value' => 6,
* 'key' => true
* ),
* 'name' => array ('value' => 'Stoyan'),
* 'family' => array ('value' => 'Stefanov'),
* 'birth_date' => array ('value' => '1975-06-20')
* );
* @return bool
*
*/
public function insertIfNotExist($table, $input)
{
return $this->connection->insertIfNotExist($table, $input);
}
/**
* Start a transaction
* @return bool TRUE on success or FALSE on failure
*/
public function beginTransaction()
{
return $this->connection->beginTransaction();
}
/**
* Commit the database changes done during a transaction that is in progress
* @return bool TRUE on success or FALSE on failure
*/
public function commit()
{
return $this->connection->commit();
}
/**
* Rollback the database changes done during a transaction that is in progress
* @return bool TRUE on success or FALSE on failure
*/
public function rollBack()
{
return $this->connection->rollBack();
}
/**
* Gets the error code and message as a string for logging
* @return string
*/
public function getError()
{
return $this->connection->getError();
}
}
|