Skip to content

Commit

Permalink
removed some old and deprecated stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jun 2, 2014
1 parent f31d4a9 commit 60893a1
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 154 deletions.
7 changes: 1 addition & 6 deletions dibi/drivers/DibiMySqliDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,7 @@ public function connect(array & $config)
}

if (isset($config['charset'])) {
$ok = FALSE;
if (version_compare(PHP_VERSION , '5.1.5', '>=')) {
// affects the character set used by mysql_real_escape_string() (was added in MySQL 5.0.7 and PHP 5.0.5, fixed in PHP 5.1.5)
$ok = @mysqli_set_charset($this->connection, $config['charset']); // intentionally @
}
if (!$ok) {
if (!@mysqli_set_charset($this->connection, $config['charset'])) {
$this->query("SET NAMES '$config[charset]'");
}
}
Expand Down
35 changes: 8 additions & 27 deletions dibi/drivers/DibiPostgreDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
/** @var int|FALSE Affected rows */
private $affectedRows = FALSE;

/** @var bool Escape method */
private $escMethod = FALSE;


/**
* @throws DibiNotSupportedException
Expand Down Expand Up @@ -103,8 +100,6 @@ public function connect(array & $config)
if (isset($config['schema'])) {
$this->query('SET search_path TO "' . $config['schema'] . '"');
}

$this->escMethod = version_compare(PHP_VERSION , '5.2.0', '>=');
}


Expand Down Expand Up @@ -266,24 +261,16 @@ public function escape($value, $type)
{
switch ($type) {
case dibi::TEXT:
if ($this->escMethod) {
if (!is_resource($this->connection)) {
throw new DibiException('Lost connection to server.');
}
return "'" . pg_escape_string($this->connection, $value) . "'";
} else {
return "'" . pg_escape_string($value) . "'";
if (!is_resource($this->connection)) {
throw new DibiException('Lost connection to server.');
}
return "'" . pg_escape_string($this->connection, $value) . "'";

case dibi::BINARY:
if ($this->escMethod) {
if (!is_resource($this->connection)) {
throw new DibiException('Lost connection to server.');
}
return "'" . pg_escape_bytea($this->connection, $value) . "'";
} else {
return "'" . pg_escape_bytea($value) . "'";
if (!is_resource($this->connection)) {
throw new DibiException('Lost connection to server.');
}
return "'" . pg_escape_bytea($this->connection, $value) . "'";

case dibi::IDENTIFIER:
// @see http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
Expand Down Expand Up @@ -313,12 +300,7 @@ public function escape($value, $type)
*/
public function escapeLike($value, $pos)
{
if ($this->escMethod) {
$value = pg_escape_string($this->connection, $value);
} else {
$value = pg_escape_string($value);
}

$value = pg_escape_string($this->connection, $value);
$value = strtr($value, array( '%' => '\\\\%', '_' => '\\\\_'));
return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
}
Expand Down Expand Up @@ -418,13 +400,12 @@ public function free()
*/
public function getResultColumns()
{
$hasTable = version_compare(PHP_VERSION , '5.2.0', '>=');
$count = pg_num_fields($this->resultSet);
$columns = array();
for ($i = 0; $i < $count; $i++) {
$row = array(
'name' => pg_field_name($this->resultSet, $i),
'table' => $hasTable ? pg_field_table($this->resultSet, $i) : NULL,
'table' => pg_field_table($this->resultSet, $i),
'nativetype'=> pg_field_type($this->resultSet, $i),
);
$row['fullname'] = $row['table'] ? $row['table'] . '.' . $row['name'] : $row['name'];
Expand Down
54 changes: 0 additions & 54 deletions dibi/libs/Dibi.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,29 +438,6 @@ public static function delete($table)
}


/********************* data types ****************d*g**/


/**
* @deprecated
*/
public static function datetime($time = NULL)
{
trigger_error(__METHOD__ . '() is deprecated; create DateTime object instead.', E_USER_WARNING);
return new DibiDateTime($time);
}


/**
* @deprecated
*/
public static function date($date = NULL)
{
trigger_error(__METHOD__ . '() is deprecated; create DateTime object instead.', E_USER_WARNING);
return new DibiDateTime($date);
}


/********************* substitutions ****************d*g**/


Expand All @@ -474,37 +451,6 @@ public static function getSubstitutes()
}


/** @deprecated */
public static function addSubst($expr, $subst)
{
trigger_error(__METHOD__ . '() is deprecated; use dibi::getSubstitutes()->expr = val; instead.', E_USER_WARNING);
self::getSubstitutes()->$expr = $subst;
}


/** @deprecated */
public static function removeSubst($expr)
{
trigger_error(__METHOD__ . '() is deprecated; use unset(dibi::getSubstitutes()->expr) instead.', E_USER_WARNING);
$substitutes = self::getSubstitutes();
if ($expr === TRUE) {
foreach ($substitutes as $expr => $foo) {
unset($substitutes->$expr);
}
} else {
unset($substitutes->$expr);
}
}


/** @deprecated */
public static function setSubstFallback($callback)
{
trigger_error(__METHOD__ . '() is deprecated; use dibi::getSubstitutes()->setCallback() instead.', E_USER_WARNING);
self::getSubstitutes()->setCallback($callback);
}


/********************* misc tools ****************d*g**/


Expand Down
9 changes: 2 additions & 7 deletions dibi/libs/DibiFluent.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,10 @@ public function __call($clause, $args)
* @param string clause name
* @return self
*/
public function clause($clause, $remove = FALSE)
public function clause($clause)
{
$this->cursor = & $this->clauses[self::$normalizer->$clause];

if ($remove) { // deprecated, use removeClause
trigger_error(__METHOD__ . '(..., TRUE) is deprecated; use removeClause() instead.', E_USER_NOTICE);
$this->cursor = NULL;

} elseif ($this->cursor === NULL) {
if ($this->cursor === NULL) {
$this->cursor = array();
}

Expand Down
22 changes: 0 additions & 22 deletions dibi/libs/DibiResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,12 @@ final public function getRowCount()
}


/**
* Returns the number of rows in a result set. Alias for getRowCount().
* @deprecated
*/
final public function rowCount()
{
trigger_error(__METHOD__ . '() is deprecated; use count($res) or $res->getRowCount() instead.', E_USER_WARNING);
return $this->getResultDriver()->getRowCount();
}


/**
* Required by the IteratorAggregate interface.
* @return DibiResultIterator
*/
final public function getIterator()
{
if (func_num_args()) {
trigger_error(__METHOD__ . ' arguments $offset & $limit have been dropped; use SQL clauses instead.', E_USER_WARNING);
}
return new DibiResultIterator($this);
}

Expand Down Expand Up @@ -603,14 +589,6 @@ final public function getColumns()
}


/** @deprecated */
public function getColumnNames($fullNames = FALSE)
{
trigger_error(__METHOD__ . '() is deprecated; use $res->getInfo()->getColumnNames() instead.', E_USER_WARNING);
return $this->getInfo()->getColumnNames($fullNames);
}


/********************* misc tools ****************d*g**/


Expand Down
36 changes: 0 additions & 36 deletions dibi/libs/DibiRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,42 +48,6 @@ public function asDateTime($key, $format = NULL)
}


/**
* Converts value to UNIX timestamp.
* @param string key
* @return int
*/
public function asTimestamp($key)
{
trigger_error(__METHOD__ . '() is deprecated.', E_USER_WARNING);
return $this->asDateTime($key, 'U');
}


/**
* Converts value to boolean.
* @param string key
* @return mixed
*/
public function asBool($key)
{
trigger_error(__METHOD__ . '() is deprecated.', E_USER_WARNING);
return $this[$key];
}


/** @deprecated */
public function asDate($key, $format = NULL)
{
trigger_error(__METHOD__ . '() is deprecated.', E_USER_WARNING);
if ($format === NULL) {
return $this->asTimestamp($key);
} else {
return $this->asDateTime($key, $format === TRUE ? NULL : $format);
}
}


/********************* interfaces ArrayAccess, Countable & IteratorAggregate ****************d*g**/


Expand Down
4 changes: 2 additions & 2 deletions examples/using-extension-methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@


// using the "prototype" to add custom method to class DibiResult
function DibiResult_prototype_fetchShuffle(DibiResult $obj)
DibiResult::extensionMethod('fetchShuffle', function(DibiResult $obj)
{
$all = $obj->fetchAll();
shuffle($all);
return $all;
}
});


// fetch complete result set shuffled
Expand Down

0 comments on commit 60893a1

Please sign in to comment.