Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • ArticleForum
  • cGenericDb
  • cGenericDbDriver
  • cGenericDbDriverMysql
  • cItemBaseAbstract
  • cItemCache
  • Item
  • ItemCollection
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the MySQL database driver for the generic db.
  4:  *
  5:  * @package Core
  6:  * @subpackage GenericDB
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Bjoern Behrens
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * MySQL database driver
 20:  *
 21:  * @package Core
 22:  * @subpackage GenericDB
 23:  */
 24: class cGenericDbDriverMysql extends cGenericDbDriver {
 25: 
 26:     /**
 27:      * (non-PHPdoc)
 28:      *
 29:      * @see cGenericDbDriver::buildJoinQuery()
 30:      */
 31:     public function buildJoinQuery($destinationTable, $destinationClass, $destinationPrimaryKey, $sourceClass, $primaryKey) {
 32:         // Build a regular LEFT JOIN
 33:         $field = "$destinationClass.$destinationPrimaryKey";
 34:         $tables = "";
 35:         $join = "LEFT JOIN $destinationTable AS $destinationClass ON " . cSecurity::toString($sourceClass . "." . $primaryKey) . " = " . cSecurity::toString($destinationClass . "." . $primaryKey);
 36:         $where = "";
 37: 
 38:         return array(
 39:             "field" => $field,
 40:             "table" => $tables,
 41:             "join" => $join,
 42:             "where" => $where
 43:         );
 44:     }
 45: 
 46:     /**
 47:      * (non-PHPdoc)
 48:      *
 49:      * @see cGenericDbDriver::buildOperator()
 50:      */
 51:     public function buildOperator($sField, $sOperator, $sRestriction) {
 52:         $sOperator = strtolower($sOperator);
 53: 
 54:         $sWhereStatement = "";
 55: 
 56:         switch ($sOperator) {
 57:             case "matchbool":
 58:                 $sqlStatement = "MATCH (%s) AGAINST ('%s' IN BOOLEAN MODE)";
 59:                 $sWhereStatement = sprintf($sqlStatement, $sField, $this->_oItemClassInstance->_inFilter($sRestriction));
 60:                 break;
 61:             case "match":
 62:                 $sqlStatement = "MATCH (%s) AGAINST ('%s')";
 63:                 $sWhereStatement = sprintf($sqlStatement, $sField, $this->_oItemClassInstance->_inFilter($sRestriction));
 64:                 break;
 65:             case "like":
 66:                 $sqlStatement = "%s LIKE '%%%s%%'";
 67:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 68:                 break;
 69:             case "likeleft":
 70:                 $sqlStatement = "%s LIKE '%s%%'";
 71:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 72:                 break;
 73:             case "likeright":
 74:                 $sqlStatement = "%s LIKE '%%%s'";
 75:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 76:                 break;
 77:             case "notlike":
 78:                 $sqlStatement = "%s NOT LIKE '%%%s%%'";
 79:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 80:                 break;
 81:             case "notlikeleft":
 82:                 $sqlStatement = "%s NOT LIKE '%s%%'";
 83:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 84:                 break;
 85:             case "notlikeright":
 86:                 $sqlStatement = "%s NOT LIKE '%%%s'";
 87:                 $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
 88:                 break;
 89:             case "fulltext":
 90: 
 91:                 break;
 92:             case "in":
 93:                 if (is_array($sRestriction)) {
 94:                     $items = array();
 95: 
 96:                     foreach ($sRestriction as $key => $sRestrictionItem) {
 97:                         $items[] = "'" . $this->_oItemClassInstance->_inFilter($sRestrictionItem) . "'";
 98:                     }
 99: 
100:                     $sRestriction = implode(", ", $items);
101:                 } else {
102:                     $sRestriction = "'" . $sRestriction . "'";
103:                 }
104: 
105:                 $sWhereStatement = implode(" ", array(
106:                     $sField,
107:                     "IN (",
108:                     $sRestriction,
109:                     ")"
110:                 ));
111:                 break;
112:             default:
113:                 $sRestriction = "'" . $this->_oItemClassInstance->_inFilter($sRestriction) . "'";
114: 
115:                 $sWhereStatement = implode(" ", array(
116:                     $sField,
117:                     $sOperator,
118:                     $sRestriction
119:                 ));
120:         }
121: 
122:         return $sWhereStatement;
123:     }
124: }
125: 
CMS CONTENIDO 4.9.3 API documentation generated by ApiGen 2.8.0