diff --git a/dibi/dibi.php b/dibi/dibi.php index ced50d1c..a8597210 100644 --- a/dibi/dibi.php +++ b/dibi/dibi.php @@ -88,6 +88,7 @@ class DibiVariable extends DibiDateTime function __construct($val) { parent::__construct($val); + trigger_error(__CLASS__ . ' is deprecated; use class DateTime instead.', E_USER_WARNING); } } @@ -584,11 +585,12 @@ class dibi /** - * @deprecated + * @return DibiDateTime */ public static function datetime($time = NULL) { - return new DibiDateTime(is_numeric($time) ? date('Y-m-d H:i:s', $time) : $time); + trigger_error(__METHOD__ . '() is deprecated; create DibiDateTime object instead.', E_USER_WARNING); + return new DibiDateTime($time); } @@ -598,7 +600,8 @@ class dibi */ public static function date($date = NULL) { - return new DibiDateTime(is_numeric($date) ? date('Y-m-d', $date) : $date); + trigger_error(__METHOD__ . '() is deprecated; create DibiDateTime object instead.', E_USER_WARNING); + return new DibiDateTime($date); } @@ -618,26 +621,19 @@ class dibi - /** - * Create a new substitution pair for indentifiers. - * @param string from - * @param string to - * @return void - */ + /** @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; } - /** - * Remove substitution pair. - * @param mixed from or TRUE - * @return void - */ + /** @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) { @@ -650,13 +646,10 @@ class dibi - /** - * Sets substitution fallback handler. - * @param callback - * @return void - */ + /** @deprecated */ public static function setSubstFallback($callback) { + trigger_error(__METHOD__ . '() is deprecated; use dibi::getSubstitutes()->setCallback() instead.', E_USER_WARNING); self::getSubstitutes()->setCallback($callback); } diff --git a/dibi/libs/DibiResult.php b/dibi/libs/DibiResult.php index 447ed583..c3b6dada 100644 --- a/dibi/libs/DibiResult.php +++ b/dibi/libs/DibiResult.php @@ -164,6 +164,7 @@ class DibiResult extends DibiObject implements IDataSource */ final public function rowCount() { + trigger_error(__METHOD__ . '() is deprecated; use count($res) or $res->getRowCount() instead.', E_USER_WARNING); return $this->getDriver()->getRowCount(); } @@ -633,6 +634,7 @@ class DibiResult extends DibiObject implements IDataSource */ public function getColumnNames($fullNames = FALSE) { + trigger_error(__METHOD__ . '() is deprecated; use $res->getInfo()->getColumnNames() instead.', E_USER_WARNING); return $this->getInfo()->getColumnNames($fullNames); } diff --git a/examples/query-language-basic-examples.php b/examples/query-language-basic-examples.php index a172ec58..834fe4e1 100644 --- a/examples/query-language-basic-examples.php +++ b/examples/query-language-basic-examples.php @@ -24,7 +24,7 @@ dibi::test(' SELECT COUNT(*) as [count] FROM [comments] WHERE [ip] LIKE %s', $ipMask, ' - AND [date] > ', dibi::date($timestamp) + AND [date] > ', new DibiDateTime($timestamp) ); // -> SELECT COUNT(*) as [count] FROM [comments] WHERE [ip] LIKE '192.168.%' AND [date] > 876693600 diff --git a/examples/using-substitutions.php b/examples/using-substitutions.php index 96bc83e9..f9fbde28 100644 --- a/examples/using-substitutions.php +++ b/examples/using-substitutions.php @@ -17,7 +17,7 @@ dibi::connect(array( // create new substitution :blog: ==> wp_ -dibi::addSubst('blog', 'wp_'); +dibi::getSubstitutes()->blog = 'wp_'; dibi::test("SELECT * FROM [:blog:items]"); // -> SELECT * FROM [wp_items] @@ -27,7 +27,7 @@ dibi::test("SELECT * FROM [:blog:items]"); // create new substitution :: (empty) ==> my_ -dibi::addSubst('', 'my_'); +dibi::getSubstitutes()->{''} = 'my_'; dibi::test("UPDATE ::table SET [text]='Hello World'"); // -> UPDATE my_table SET [text]='Hello World' @@ -48,7 +48,7 @@ function substFallBack($expr) } // define callback -dibi::setSubstFallBack('substFallBack'); +dibi::getSubstitutes()->setCallback('substFallBack'); // define substitutes as constants define('SUBST_ACCOUNT', 'eshop_');