r609 - in src/classes: DB OSQL

From: <voxusAT@ATshadanakar.org>
Date: Wed, 20 Jul 2005 19:39:47 +0400 (MSD)

Author: voxus
Date: 2005-07-20 19:39:46 +0400 (Wed, 20 Jul 2005)
New Revision: 609

Removed:
   src/classes/OSQL/GroupBy.class.php
Modified:
   src/classes/DB/DB.class.php
   src/classes/DB/DBFactory.class.php
   src/classes/DB/Transaction.class.php
   src/classes/DB/TransactionQueue.class.php
   src/classes/OSQL/FromTable.class.php
   src/classes/OSQL/InsertOrUpdateQuery.class.php
   src/classes/OSQL/OSQL.class.php
   src/classes/OSQL/OrderBy.class.php
   src/classes/OSQL/PreQuery.class.php
   src/classes/OSQL/QuerySkeleton.class.php
   src/classes/OSQL/SelectQuery.class.php
   src/classes/OSQL/SelectQuerySkeleton.class.php
   src/classes/OSQL/UpdateQuery.class.php
Log:
* mostly minor random cosmetics changes
- dropped customHead support at selectQuery
        hint: use DBRaw if you're really hate your karma
- finally dropped support of 'field.table' fields support
        hint: use DBField

Modified: src/classes/DB/DB.class.php
===================================================================
--- src/classes/DB/DB.class.php 2005-07-20 14:04:12 UTC (rev 608)
+++ src/classes/DB/DB.class.php 2005-07-20 15:39:46 UTC (rev 609)
@@ -219,4 +219,4 @@
                                         : $this->quoteField($field);
                 }
         }
-?>
+?>
\ No newline at end of file

Modified: src/classes/DB/DBFactory.class.php
===================================================================
--- src/classes/DB/DBFactory.class.php 2005-07-20 14:04:12 UTC (rev 608)
+++ src/classes/DB/DBFactory.class.php 2005-07-20 15:39:46 UTC (rev 609)
@@ -11,9 +11,9 @@
  ***************************************************************************/
 /* $Id$ */
 
- class DBFactory
+ final class DBFactory
         {
- private static $defaultDB = null;
+ private static $defaultDB = null;
         
                 private function __construct() {/* generic hack :-) */}
 

Modified: src/classes/DB/Transaction.class.php
===================================================================
--- src/classes/DB/Transaction.class.php 2005-07-20 14:04:12 UTC (rev 608)
+++ src/classes/DB/Transaction.class.php 2005-07-20 15:39:46 UTC (rev 609)
@@ -13,6 +13,8 @@
 
         final class Transaction
         {
+ private function __construct() {/*-*/}
+
                 public static function immediate(DB $db)
                 {
                         return new DBTransaction($db);

Modified: src/classes/DB/TransactionQueue.class.php
===================================================================
--- src/classes/DB/TransactionQueue.class.php 2005-07-20 14:04:12 UTC (rev 608)
+++ src/classes/DB/TransactionQueue.class.php 2005-07-20 15:39:46 UTC (rev 609)
@@ -13,7 +13,7 @@
 
         final class TransactionQueue extends TransactionSkeleton implements Query
         {
- private $queue = null;
+ private $queue = null;
                 
                 public function __construct(DB $db)
                 {

Modified: src/classes/OSQL/FromTable.class.php
===================================================================
--- src/classes/OSQL/FromTable.class.php 2005-07-20 14:04:12 UTC (rev 608)
+++ src/classes/OSQL/FromTable.class.php 2005-07-20 15:39:46 UTC (rev 609)
@@ -29,10 +29,12 @@
                 public function toString(DB $db)
                 {
                         if ($this->table instanceof SelectQuery)
- return "({$this->table->toString($db)}) AS {$db->quoteTable($this->alias)}";
+ return
+ "({$this->table->toString($db)}) AS {$db->quoteTable($this->alias)}";
                         else
- return $db->quoteTable($this->table)
- .($this->alias ? ' AS '.$db->quoteTable($this->alias) : '');
+ return
+ $db->quoteTable($this->table).
+ ($this->alias ? ' AS '.$db->quoteTable($this->alias) : '');
                 }
 
                 public function getTable()

Deleted: src/classes/OSQL/GroupBy.class.php
===================================================================
--- src/classes/OSQL/GroupBy.class.php 2005-07-20 14:04:12 UTC (rev 608)
+++ src/classes/OSQL/GroupBy.class.php 2005-07-20 15:39:46 UTC (rev 609)
@@ -1,14 +0,0 @@
-<?php
-/***************************************************************************
- * Copyright (C) 2005 by Anton Lebedevich *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-/* $Id$ */
-
- class GroupBy extends FieldTable {/*_*/}
-?>
\ No newline at end of file

Modified: src/classes/OSQL/InsertOrUpdateQuery.class.php
===================================================================
--- src/classes/OSQL/InsertOrUpdateQuery.class.php 2005-07-20 14:04:12 UTC (rev 608)
+++ src/classes/OSQL/InsertOrUpdateQuery.class.php 2005-07-20 15:39:46 UTC (rev 609)
@@ -40,7 +40,7 @@
                         else
                                 return $this->set($var, 'false');
                 }
-
+
                 /**
                  * Adds values from associative array
                  *

Modified: src/classes/OSQL/OSQL.class.php
===================================================================
--- src/classes/OSQL/OSQL.class.php 2005-07-20 14:04:12 UTC (rev 608)
+++ src/classes/OSQL/OSQL.class.php 2005-07-20 15:39:46 UTC (rev 609)
@@ -11,7 +11,7 @@
  ***************************************************************************/
 /* $Id$ */
 
- class OSQL
+ final class OSQL
         {
                 private function __construct() {}
                 
@@ -25,7 +25,7 @@
                         return new InsertQuery();
                 }
                 
- public static function update($table)
+ public static function update($table = null)
                 {
                         return new UpdateQuery($table);
                 }

Modified: src/classes/OSQL/OrderBy.class.php
===================================================================
--- src/classes/OSQL/OrderBy.class.php 2005-07-20 14:04:12 UTC (rev 608)
+++ src/classes/OSQL/OrderBy.class.php 2005-07-20 15:39:46 UTC (rev 609)
@@ -35,14 +35,10 @@
 
                 public function toString(DB $db)
                 {
- $string = parent::toString($db);
+ $string =
+ parent::toString($db).
+ $this->direction->decide(' ASC', ' DESC');
 
- if ($this->direction->isTrue())
- $string .= ' ASC';
-
- if ($this->direction->isFalse())
- $string .= ' DESC';
-
                         return $string;
                 }
         }

Modified: src/classes/OSQL/PreQuery.class.php
===================================================================
--- src/classes/OSQL/PreQuery.class.php 2005-07-20 14:04:12 UTC (rev 608)
+++ src/classes/OSQL/PreQuery.class.php 2005-07-20 15:39:46 UTC (rev 609)
@@ -174,7 +174,8 @@
                                 $query->
                                         dropFields()->
                                         arrayGet($this->fields)->
- get('id'); // since we handle only identifiable objects
+ // since we handle only identifiable objects
+ get(new DBField('id', $this->dao->getTable()));
 
                         if ($this->order) {
                                 $query->orderBy($this->order, $this->dao->getTable());

Modified: src/classes/OSQL/QuerySkeleton.class.php
===================================================================
--- src/classes/OSQL/QuerySkeleton.class.php 2005-07-20 14:04:12 UTC (rev 608)
+++ src/classes/OSQL/QuerySkeleton.class.php 2005-07-20 15:39:46 UTC (rev 609)
@@ -13,8 +13,8 @@
 
         class QuerySkeleton implements Query
         {
- protected $where = array(); // where clauses
- protected $whereLogic = array(); // logic between where's
+ protected $where = array(); // where clauses
+ protected $whereLogic = array(); // logic between where's
 
                 public function where(LogicalObject $exp, $logic = null)
                 {

Modified: src/classes/OSQL/SelectQuery.class.php
===================================================================
--- src/classes/OSQL/SelectQuery.class.php 2005-07-20 14:04:12 UTC (rev 608)
+++ src/classes/OSQL/SelectQuery.class.php 2005-07-20 15:39:46 UTC (rev 609)
@@ -50,9 +50,7 @@
                         }
 
                         $query =
- 'SELECT '.($this->distinct ? 'DISTINCT' : '').
- implode(' ', $this->customHead).
- ' '.
+ 'SELECT '.($this->distinct ? 'DISTINCT ' : '').
                                 implode(', ', $fieldList);
 
                         $fromString = "";

Modified: src/classes/OSQL/SelectQuerySkeleton.class.php
===================================================================
--- src/classes/OSQL/SelectQuerySkeleton.class.php 2005-07-20 14:04:12 UTC (rev 608)
+++ src/classes/OSQL/SelectQuerySkeleton.class.php 2005-07-20 15:39:46 UTC (rev 609)
@@ -9,7 +9,10 @@
  * (at your option) any later version. *
  * *
  ***************************************************************************/
+/* $Id$ */
 
+ class GroupBy extends FieldTable {/*_*/}
+
         /**
          * mostly for write-only methods (setters)
         **/
@@ -25,8 +28,6 @@
                 protected $order = array();
                 protected $group = array();
 
- protected $customHead = array();
-
                 public function distinct()
                 {
                         $this->distinct = true;
@@ -39,13 +40,6 @@
                         return $this;
                 }
 
- public function addCustomHead($value)
- {
- $this->customHead[] = strtoupper($value);
-
- return $this;
- }
-
                 public function joinQuery(SelectQuery $query, LogicalObject $logic, $alias)
                 {
                         $this->from[] = new SQLQueryJoin($query, $logic, $alias);
@@ -76,7 +70,10 @@
                         if ($field instanceof DBString)
                                 $this->order[] = new OrderBy($field);
                         else
- $this->order[] = new OrderBy(new DBField($field, $this->getLastTable($table)));
+ $this->order[] =
+ new OrderBy(
+ new DBField($field, $this->getLastTable($table))
+ );
 
                         return $this;
                 }
@@ -106,7 +103,10 @@
                         if ($field instanceof DBField)
                                 $this->group[] = new GroupBy($field);
                         else
- $this->group[] = new GroupBy(new DBField($field, $this->getLastTable($table)));
+ $this->group[] =
+ new GroupBy(
+ new DBField($field, $this->getLastTable($table))
+ );
 
                         return $this;
                 }
@@ -142,9 +142,13 @@
                                         throw new WrongArgumentException('unknown field type');
 
                         } elseif (false !== strpos($field, '*'))
- throw new WrongArgumentException('do not fsck with us: specify fields explicitly');
+ throw new WrongArgumentException(
+ 'do not fsck with us: specify fields explicitly'
+ );
                         elseif (false !== strpos($field, '.'))
- list($table, $fieldName) = explode('.', $field, 2);
+ throw new WrongArgumentException(
+ 'forget about dot: use DBField'
+ );
                         else
                                 $fieldName = $field;
                                 
@@ -199,7 +203,10 @@
                 {
                         $this->fields[] =
                                 new SQLFunction(
- new DBField($field, $this->getLastTable()),
+ new DBField(
+ $field,
+ $this->getLastTable()
+ ),
                                         $function,
                                         $alias
                                 );

Modified: src/classes/OSQL/UpdateQuery.class.php
===================================================================
--- src/classes/OSQL/UpdateQuery.class.php 2005-07-20 14:04:12 UTC (rev 608)
+++ src/classes/OSQL/UpdateQuery.class.php 2005-07-20 15:39:46 UTC (rev 609)
@@ -45,7 +45,7 @@
                                         $sets[] = $db->quoteField($var).' = '.$db->quoteValue($val);
                         }
                         
- $query .= implode(', ',$sets);
+ $query .= implode(', ', $sets);
                         
                         $query .= parent::toString($db);
 
Received on Wed Jul 20 2005 - 19:39:47 MSD

This archive was generated by hypermail 2.2.0 : Sat Oct 27 2007 - 19:28:37 MSD