Overview

Packages

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