コード例 #1
0
ファイル: Injector.php プロジェクト: bylexus/php-injector
 /**
  * gets a doc comment block as string and tries to extract type information
  * from it, storing in the param info array given.
  *
  * Looks for doc comments like "@param <type> <varname> ....".
  */
 protected function extractTypeInfos($docComment, &$paramInfo)
 {
     $matches = $this->matchParams($docComment);
     foreach ($matches['varname'] as $key => $varname) {
         if (!empty($matches['type'][$key]) && isset($paramInfo[$varname])) {
             $paramInfo[$varname]['type'] = $matches['type'][$key];
             $conditionStr = !empty($matches['condition'][$key]) ? $matches['condition'][$key] : null;
             if ($conditionStr) {
                 $cond = Condition::getCondition($paramInfo[$varname]['type'], $conditionStr);
                 $paramInfo[$varname]['condition'] = $cond;
             }
         }
     }
 }
コード例 #2
0
 /**
  * @param Condition $_condition
  * @return array
  */
 public function selectDesc(Condition $_condition)
 {
     /* ## LOGGER ## */
     if (isset($this->logger)) {
         $this->logger->DEBUG('select: ' . $_condition->toString());
     }
     if (empty($_condition)) {
         throw new UndefinedRowException('null');
     }
     $table = $this->connection->escape($this->table);
     $primary = $this->connection->escape($this->primary);
     $key = $this->connection->escape($_condition->getKey());
     $value = $this->connection->escape($_condition->getValue());
     $condition = $this->connection->escape($_condition->getCondition());
     $sql = 'SELECT * FROM `' . $table . '` WHERE `' . $key . '` ' . $_condition . ' \'' . $value . '\' ORDER BY `' . $primary . '` DESC;';
     $result = $this->connection->send($sql);
     if (mysql_num_rows($result) < 0) {
         throw new UndefinedRowException('undefined ' . $key . ' ' . $_condition . ' ' . $value);
     }
     $values = array();
     while ($value = mysql_fetch_assoc($result)) {
         $values[] = $value;
     }
     return $values;
 }