/** * Quotes primitive value with its primitve variable (alias.var) * @param mixed $v * @param string $pvar * @return true|string (error message if string) */ private function _qq(&$v, &$pvar) { // unquote pvar $pvar_ = $this->uq($pvar); // split primitive var to alias and var list($alias, $var) = explode('.', $pvar_); if (!$alias || !$var) { return "Invalid primitive variable [{$pvar}]"; } // get the class for alias if (!($class = $this->aliases[$alias])) { return "No class found for alias [{$alias}]"; } // get class map if (!($cm = $this->em->getClassMap($class))) { return "No class map for [{$class}]"; } // is var 'oid'? if ($var == 'oid') { // replace var name with column name $pvar = $this->qid($alias) . '.' . $this->qid($cm->getOidColumn()); } else { // get field map (for non-oid field) if (!($fm = $cm->getField($var))) { return "No field map for [{$class}::{$var}]"; } // replace var name with column name $pvar = $this->qid($alias) . '.' . $this->qid($fm->getColumnName()); // quote value $v = $this->q($v, $fm); } return true; }
/** * Makes a cache key for a class * * Since EZPDO allows a user to change database (DSN) at runtime (see * {@link epManager::setDsn()}), it is important to use the current * DSN of the class in generating the cache key. * * @param string $class The class name * @param string $extra The extra string (mostly for locking type) * @return false|string */ protected function _key($class, $extra = '') { if (!($cm =& self::$em->getClassMap($class))) { return false; } if (!($dsn = $cm->getDsn())) { return false; } return md5($dsn . $class . $extra); }
/** * Prepare database if not exists * @param string $class * @param string $rtable (relationship table, only used if class is epObjectRelation) * @return boolean */ public function prepareDb($class, $rtable = false) { // if relation table is given, set it to runtime manager if ($rtable) { self::$em->setRelationTable($rtable); } // get class map for class if (!($cm = self::$em->getClassMap($class))) { return false; } // no table for abstract class if ($cm->isAbstract()) { return true; } return self::$db->create($cm); }