summaryrefslogtreecommitdiff
path: root/framework/Testing/Data/Schema/oci/TOciCommandBuilder.php
diff options
context:
space:
mode:
authorctrlaltca@gmail.com <>2011-06-20 14:26:39 +0000
committerctrlaltca@gmail.com <>2011-06-20 14:26:39 +0000
commitd4b19712c271c3bf9d16909768c4bd84d617afd5 (patch)
tree103fb4f57818c7eaf2a9591d237299ea146196fd /framework/Testing/Data/Schema/oci/TOciCommandBuilder.php
parenta57ead00a69cd5240dd7549fa3a7da8d4e717749 (diff)
killed the experimental activecontrols implementation backported from yii
Diffstat (limited to 'framework/Testing/Data/Schema/oci/TOciCommandBuilder.php')
-rwxr-xr-xframework/Testing/Data/Schema/oci/TOciCommandBuilder.php122
1 files changed, 0 insertions, 122 deletions
diff --git a/framework/Testing/Data/Schema/oci/TOciCommandBuilder.php b/framework/Testing/Data/Schema/oci/TOciCommandBuilder.php
deleted file mode 100755
index ed3e8c3b..00000000
--- a/framework/Testing/Data/Schema/oci/TOciCommandBuilder.php
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-/**
- * TOciCommandBuilder class file.
- *
- * @author Ricardo Grana <rickgrana@yahoo.com.br>
- * @link http://www.yiiframework.com/
- * @copyright Copyright &copy; 2008-2009 Yii Software LLC
- * @license http://www.yiiframework.com/license/
- */
-
-prado::using('System.Testing.Data.Schema.TDbCommandBuilder');
-
-/**
- * TOciCommandBuilder provides basic methods to create query commands for tables.
- *
- * @author Ricardo Grana <rickgrana@yahoo.com.br>
- * @version $Id: TOciCommandBuilder.php 2679 2009-06-15 07:49:42Z Christophe.Boulain $
- * @package System.Testing.Data.Schema.oci
- * @since 1.0.5
- */
-class TOciCommandBuilder extends TDbCommandBuilder
-{
- /**
- * @var integer the last insertion ID
- */
- public $returnID;
-
- /**
- * Returns the last insertion ID for the specified table.
- * @param mixed the table schema ({@link TDbTableSchema}) or the table name (string).
- * @return mixed last insertion id. Null is returned if no sequence name.
- */
- public function getLastInsertID($table)
- {
- return $this->returnID;
- }
-
- /**
- * Alters the SQL to apply LIMIT and OFFSET.
- * Default implementation is applicable for PostgreSQL, MySQL and SQLite.
- * @param string SQL query string without LIMIT and OFFSET.
- * @param integer maximum number of rows, -1 to ignore limit.
- * @param integer row offset, -1 to ignore offset.
- * @return string SQL with LIMIT and OFFSET
- */
- public function applyLimit($sql,$limit,$offset)
- {
- if (($limit < 0) and ($offset < 0)) return $sql;
-
- $filters = array();
- if($offset>0){
- $filters[] = 'rowNumId >= '.(int)$offset;
- }
-
- if($limit>=0){
- $filters[]= 'rownum <= '.(int)$limit;
- }
-
- if (count($filters) > 0){
- $filter = implode(' and ', $filters);
- $filter= " WHERE ".$filter;
- }else{
- $filter = '';
- }
-
-
- $sql = <<<EOD
- WITH USER_SQL AS ({$sql}),
- PAGINATION AS (SELECT USER_SQL.*, rownum as rowNumId FROM USER_SQL)
- SELECT *
- FROM PAGINATION
- {$filter}
-EOD;
-
- return $sql;
- }
-
- /**
- * Creates an INSERT command.
- * @param mixed the table schema ({@link TDbTableSchema}) or the table name (string).
- * @param array data to be inserted (column name=>column value). If a key is not a valid column name, the corresponding value will be ignored.
- * @return TDbCommand insert command
- */
- public function createInsertCommand($table,$data)
- {
- $this->ensureTable($table);
- $fields=array();
- $values=array();
- $placeholders=array();
- foreach($data as $name=>$value)
- {
- if(($column=$table->getColumn($name))!==null && ($value!==null || $column->allowNull))
- {
- $fields[]=$column->rawName;
- if($value instanceof TDbExpression)
- $placeholders[]=(string)$value;
- else
- {
- $placeholders[]=':'.$name;
- $values[':'.$name]=$column->typecast($value);
- }
- }
- }
-
- $sql="INSERT INTO {$table->rawName} (".implode(', ',$fields).') VALUES ('.implode(', ',$placeholders).')';
-
- if(is_string($table->primaryKey))
- {
- $sql.=" RETURNING ".$table->primaryKey." INTO :RETURN_ID";
- $command=$this->getDbConnection()->createCommand($sql);
- $command->bindParam(':RETURN_ID', $this->returnID, PDO::PARAM_INT, 12);
- $table->sequenceName='RETURN_ID';
- }
- else
- $command=$this->getDbConnection()->createCommand($sql);
-
- foreach($values as $name=>$value)
- $command->bindValue($name,$value);
-
- return $command;
- }
-}