From 2e2fa723c5584bd1c8ef74e653eafc0ee15eaab1 Mon Sep 17 00:00:00 2001 From: mitaichik Date: Fri, 4 Dec 2015 20:30:49 +0300 Subject: [PATCH] fix conflicts with new versions of Yii1 and add composer file --- RDbCommand.php | 18 +++++++++++------- composer.json | 12 ++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 composer.json diff --git a/RDbCommand.php b/RDbCommand.php index cb4887f..dba7278 100644 --- a/RDbCommand.php +++ b/RDbCommand.php @@ -33,10 +33,11 @@ public function insertIgnore($table, $columns) * The method will properly escape the column names, and bind the values to be inserted. * @param string $table the table that new rows will be inserted into. * @param array $columns the column data (name=>value) to be inserted into the table - * or array(array(name=>value),array(name=>value)). + * or array(array(name=>value),array(name=>value)). * @param array $update the column data (name=>value) to be update * @param string $ignore '' or 'IGNORE' - * @return integer number of rows affected by the execution. + * @return int number of rows affected by the execution. + * @throws CDbException */ public function insertUpdate($table, $columns, $update=array(), $ignore='') { @@ -44,18 +45,18 @@ public function insertUpdate($table, $columns, $update=array(), $ignore='') { throw new CDbException(Yii::t('ext.RDbCommand', 'Table name should be a valid string.')); } - + if(!$columns || !is_array($columns)) { throw new CDbException(Yii::t('ext.RDbCommand', 'Columns should be a valid one demention array.')); } - + list($names, $placeholders, $params) = $this->_insert($columns); $sql="INSERT {$ignore} INTO " . $this->getConnection()->quoteTableName($table) . ' (' . implode(', ',$names) . ') VALUES ' . implode(', ', $placeholders); - + list($lines, $params) = $this->_updatePrepare($update, $params); if($lines) { @@ -92,6 +93,8 @@ protected function _insert($columns) /** * Prepare $names, $placeholders, $params * @param array $columns + * @param string $iterat + * @param array $params * @return array array($names, $placeholders, $params) */ protected function _insertPrepare($columns, $iterat='', $params=array()) @@ -121,6 +124,7 @@ protected function _insertPrepare($columns, $iterat='', $params=array()) /** * Prepare $lines, $params * @param array $columns + * @param array $params * @return array array($lines, $params) */ protected function _updatePrepare($columns, $params=array()) @@ -130,13 +134,13 @@ protected function _updatePrepare($columns, $params=array()) { if($value instanceof CDbExpression) { - $lines[]=$this->_connection->quoteColumnName($name) . '=' . $value->expression; + $lines[]=$this->getConnection()->quoteColumnName($name) . '=' . $value->expression; foreach($value->params as $n => $v) $params[$n] = $v; } else { - $lines[]=$this->_connection->quoteColumnName($name) . '=:' . $name; + $lines[]=$this->getConnection()->quoteColumnName($name) . '=:' . $name; $params[$this->_paramName(':' . $name, $params)]=$value; } } diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..d5daad8 --- /dev/null +++ b/composer.json @@ -0,0 +1,12 @@ +{ + "name": "RSol/RDB", + "description": "Yii extention for MySQL database", + "version": "0.1.1", + "type": "library", + "require": { + "yiisoft/yii": ">=1.1.1, <2" + }, + "autoload": { + "classmap" : ["RDbCommand.php", "RDbConnection.php"] + } +} \ No newline at end of file