只取第一行
@param $sQuery
@param array $aParam
@return mixed
@throws TangoException
431871
public function getRow($sQuery, array $aParam = []) {

		$oResult = $this->_query($sQuery, $aParam, FALSE);

		$aRow = $oResult->fetch();

		if ($aRow) {
			static::_ColumnConvertScan($oResult);
			$aRow = static::_ColumnConvertDo($aRow);
		}

		$oResult->closeCursor();

		return $aRow;
	}
1045898
public function execute($commandlist, $type, $arg = null, $attr = null)
    {
        $commandNames = \explode('.', $commandlist);
        // lookup commands
        $app = $this->getApplication();
        $cmd = $app;

        if ($commandNames[0] === 'app') {
            unset($commandNames[0]);
        }

        $this->logger->debug('Finding command ' . \get_class($cmd));

        foreach ($commandNames as $commandName) {
            if (!$cmd->hasCommands()) {
                break;
            }

            $this->logger->debug('Finding command ' . $commandName);
            $cmd = $cmd->getCommand($commandName);
            $this->logger->debug('Found command class ' . \get_class($cmd));
        }

        // 'arg' or 'opt' require the argument name and attribute type
        if ($attr === null || (\in_array($type, ['arg', 'opt'], true) && $arg === null)) {
            throw new InvalidArgumentException("'arg' or 'opt' require the attribute type.");
        }

        try {
            if (!$cmd) {
                throw new \RuntimeException('Can not find command.');
            }

            switch ($type) {
                case 'arg':
                    $idx = (int) $arg;

                    if (($argument = $cmd->findArgument($idx)) === null) {
                        throw new UndefinedArgumentException("Undefined argument at $idx");
                    }

                    switch ($attr) {
                        case 'suggestions':
                            if ($values = $argument->getSuggestions()) {
                                $this->outputValues($values, $this->getOptions());

                                return;
                            }
                            break;

                        case 'valid-values':
                            if ($values = $argument->getValidValues()) {
                                $this->outputValues($values, $this->getOptions());

                                return;
                            }
                            break;
                    }
                    break;
                case 'opts':
                    $options = $cmd->getOptionCollection();
                    $values = [];
                    foreach ($options as $opt) {
                        if ($opt->short) {
                            $values[] = '-' . $opt->short;
                        } elseif ($opt->long) {
                            $values[] = '--' . $opt->long;
                        }
                    }
                    echo \implode(' ', $values), "\n";

                    return;
                case 'opt':
                    $options = $cmd->getOptionCollection();
                    $option = $options->find($arg);
                    if (!$option) {
                        throw new UndefinedOptionException("Option '$arg' not found", $cmd, $options);
                    }
                    switch ($attr) {
                        case 'isa':
                            echo $option->isa;

                            return;

                        case 'valid-values':
                            if ($values = $option->getValidValues()) {
                                $this->outputValues($values, $this->getOptions());

                                return;
                            }
                            break;
                        case 'suggestions':
                            if ($values = $option->getSuggestions()) {
                                $this->outputValues($values, $this->getOptions());

                                return;
                            }
                            break;
                    }
                    break;
                default:
                    throw new \RuntimeException("Invalid type '$type', valid types are 'arg', 'opt', 'opts'");
            }
        } catch (UnsupportedShellException $e) {
            \fwrite(STDERR, $e->getMessage() . "\n");
            \fwrite(STDERR, "Supported shells: zsh, bash\n");
        } catch (UndefinedOptionException $e) {
            \fwrite(STDERR, $e->command->getSignature() . "\n");
            \fwrite(STDERR, $e->getMessage() . "\n");
            \fwrite(STDERR, "Valid options:\n");
            foreach ($e->getOptions() as $opt) {
                if ($opt->short && $opt->long) {
                    \fwrite(STDERR, ' ' . $opt->short . '|' . $opt->long);
                } elseif ($opt->short) {
                    \fwrite(STDERR, ' ' . $opt->short);
                } elseif ($opt->long) {
                    \fwrite(STDERR, ' ' . $opt->long);
                }
                \fwrite(STDERR, "\n");
            }
        }
    }
534479
public function execute($params = null) {
		if ($params === null) {
			$params = [];
		}

		try {
			$this->stmt->execute($params);

			return new QueryResult($this->stmt, $this->pdo);
		} catch (PDOException $e) {
			throw $this->exAdapter->adapt($e, $this->stmt, $params);
		}
	}
345550
public function execute($params = array()){
    
        if($this->entity instanceof OneToOneJoinInterface) { 
           if(array_key_exists('locale', $params)) {
               $this->getQueryBuilder()->where($params['locale']);
           }
            
            $this->getQueryBuilder()->join($this->entity->getJoinRelationships());
        }
     
        $this->getQueryBuilder()->where($params);
        
        $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::GET_ALL_ITEMS_QUERY, QueryBuilder::PARENT_AND_CHILD);

        $result = $this->query($query);
        $param = get_class($this->entity) . 's';
             
        return array($param => $result, $param . 'Count' => $this->getTotalRowCount());
    }
776581
public function runWithParams($params)
    {
        $args = $this->controller->bindActionParams($this, $params);
        Log::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()' . __METHOD__);
        if (Zilf::$app->requestedParams === null) {
            Zilf::$app->requestedParams = $args;
        }

        return call_user_func_array([$this->controller, $this->actionMethod], $args);
    }
738718
public function execute(array $params = []) : Result
    {
        $params = array_replace($this->parameters, $params);

        if (
            empty($this->fields)
            && empty($this->avgAggregate)
            && empty($this->countAggregate)
            && empty($this->minAggregate)
            && empty($this->maxAggregate)
            && empty($this->sumAggregate)
        ) {
            $this->fields = ['*'];
        }

        return $this->connection->select($this, $params);
    }
186269
public function query($sQuery)
    {
        if (empty($this->oDb)) {
            $this->connect();
        }

        return $this->oDb->query($sQuery);
    }
1108921
public function prepare($sQuery)
    {
        $sQuery = $this->replaceConstants($sQuery);
        $this->iQueryCount++;
        $this->sLastQuery = $sQuery;

        return $this->oDb->prepare($sQuery);
    }
1309622
public function execute (Array $params)
    {
        try {
            $this->_validateParameters($params);
            
            // スケルトンファイルを取得する
            $skeleton = $this->_getSkeletonFile();

            // スケルトンファイルのコンテンツを置換
            $skeleton = str_replace('${command}', $this->command_name, $skeleton);
            file_put_contents(LIB.'/'.APP.'/Commands/'.$this->command_name.'.php', $skeleton);

            $this->log($this->command_name.' command is created!', 'success');
        
        } catch (\Exception $e) {
            $this->errorLog($e->getMessage());
        }
    }
471404
public function execute(array $params = []) : array
    {
        foreach ($params as $paramName => $paramValue) {
            $type = is_int($paramValue) ? \SQLITE3_INTEGER : \SQLITE3_TEXT;
            $this->getStatement()->bindValue($paramName, $paramValue, $type);
        }
        $result = $this->getStatement()->execute();

        $results = [];
        while ($row = $result->fetchArray(\SQLITE3_ASSOC)) {
            $results[] = $row;
        }

        return $results;
    }
159230
public function execute($params = array(), $requestParams = array()){
      
        $deleteParams = $params;
        if(count($requestParams) > 0) {
            $deleteParams = $requestParams;
        }
        $this->beginTransaction();
        $firstResult = null;
        try{
            //first delete the child tables
            $this->deleteI18nLocales($deleteParams); 
            $this->deleteOneToOneRows($deleteParams);

            //now delete the main tables
            $this->getQueryBuilder()->where($deleteParams);
            $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::DELETE_QUERY);

            $firstResult = $this->query($query);

            $this->commitTransaction();
        }catch(Exception $e){
            $this->logger->addError($e->getMessage());
            $this->rollbackTransaction();
        }
        return $firstResult;

    }
168806
public function run($args)
	{
		if(!isset($args[0],$args[1]))
		{
			echo "Error: both model class and view name are required.\n";
			echo $this->getHelp();
			return 1;
		}
		$scenario=isset($args[2]) ? $args[2] : '';
		$modelClass=Yii::import($args[0],true);
		$model=new $modelClass($scenario);
		$attributes=$model->getSafeAttributeNames();

		$templatePath=$this->templatePath===null?YII_PATH.'/cli/views/shell/form':$this->templatePath;
		$viewPath=Yii::getPathOfAlias($args[1]);
		$viewName=basename($viewPath);
		$viewPath.='.php';
		$params=array(
			'modelClass'=>$modelClass,
			'viewName'=>$viewName,
			'attributes'=>$attributes,
		);
		$list=array(
			basename($viewPath)=>array(
				'source'=>$templatePath.'/form.php',
				'target'=>$viewPath,
				'callback'=>array($this,'generateForm'),
				'params'=>$params,
			),
		);

		$this->copyFiles($list);

		$actionFile=$templatePath.'/action.php';
		if(!is_file($actionFile))  // fall back to default ones
			$actionFile=YII_PATH.'/cli/views/shell/form/action.php';

		echo "The following form view has been successfully created:\n";
		echo "\t$viewPath\n\n";
		echo "You may use the following code in your controller action:\n\n";
		echo $this->renderFile($actionFile,$params,true);
		echo "\n";
	}
311843
protected function execute($query, $parameters = "")
    {
        try {
            $this->sQuery = @$this->pdo->prepare($query);
            $this->bindMore($parameters);
            if (!empty($this->parameters)) {
                foreach ($this->parameters as $param) {
                    $parameters = explode("\x7F", $param);
                    $this->sQuery->bindParam($parameters[0], $parameters[1]);
                }
            }
            $this->success = $this->sQuery->execute();
        } catch (PDOException $e) {
            // 服务端断开时重连一次
            if ($e->errorInfo[1] == 2006 || $e->errorInfo[1] == 2013) {
                $this->closeConnection();
                $this->connect();

                try {
                    $this->sQuery = $this->pdo->prepare($query);
                    $this->bindMore($parameters);
                    if (!empty($this->parameters)) {
                        foreach ($this->parameters as $param) {
                            $parameters = explode("\x7F", $param);
                            $this->sQuery->bindParam($parameters[0], $parameters[1]);
                        }
                    }
                    $this->success = $this->sQuery->execute();
                } catch (PDOException $ex) {
                    $this->rollBackTrans();
                    throw $ex;
                }
            } else {
                $this->rollBackTrans();
                $msg = $e->getMessage();
                $err_msg = "SQL:".$this->lastSQL()." ".$msg;
                $exception = new \PDOException($err_msg, (int)$e->getCode());
                throw $exception;
            }
        }
        $this->parameters = array();
    }
1360244
public function single($query = '', $params = null)
    {
        $query = trim($query);
        if (empty($query)) {
            $query = $this->build();
            if (!$params) {
                $params = $this->getBindValues();
            }
        }

        $this->resetAll();
        $this->lastSql = $query;

        $this->execute($query, $params);
        return $this->sQuery->fetchColumn();
    }
526940
function execute($m, $params=null, $paramtypes=null, $msgID=null)
		{
			if (is_object($m))
			{
				// watch out: if $m is an xmlrpcmsg obj, this will raise a warning: no id memeber...
				$methName = $m->method();
				$msgID = $m->id;
			}
			else
			{
				$methName = $m;
			}
			$sysCall = $this->allow_system_funcs && strpos($methName, "system.") === 0;
			$dmap = $sysCall ? $GLOBALS['_xmlrpcs_dmap'] : $this->dmap;

			if(!isset($dmap[$methName]['function']))
			{
				// No such method
				return new jsonrpcresp(0,
					$GLOBALS['xmlrpcerr']['unknown_method'],
					$GLOBALS['xmlrpcstr']['unknown_method']);
			}

			// Check signature
			if(isset($dmap[$methName]['signature']))
			{
				$sig = $dmap[$methName]['signature'];
				if (is_object($m))
				{
					list($ok, $errstr) = $this->verifySignature($m, $sig);
				}
				else
				{
					list($ok, $errstr) = $this->verifySignature($paramtypes, $sig);
				}
				if(!$ok)
				{
					// Didn't match.
					return new jsonrpcresp(
						0,
						$GLOBALS['xmlrpcerr']['incorrect_params'],
						$GLOBALS['xmlrpcstr']['incorrect_params'] . ": ${errstr}"
					);
				}
			}

			$func = $dmap[$methName]['function'];
			// let the 'class::function' syntax be accepted in dispatch maps
			if(is_string($func) && strpos($func, '::'))
			{
				$func = explode('::', $func);
			}
			// verify that function to be invoked is in fact callable
			if(!is_callable($func))
			{
				error_log("XML-RPC: ".__METHOD__.": function $func registered as method handler is not callable");
				return new jsonrpcresp(
					0,
					$GLOBALS['xmlrpcerr']['server_error'],
					$GLOBALS['xmlrpcstr']['server_error'] . ": no function matches method"
				);
			}

			// If debug level is 3, we should catch all errors generated during
			// processing of user function, and log them as part of response
			if($this->debug > 2)
			{
				$GLOBALS['_xmlrpcs_prev_ehandler'] = set_error_handler('_xmlrpcs_errorHandler');
			}
			try
			{
				if (is_object($m))
				{
					if($sysCall)
					{
						$r = call_user_func($func, $this, $m);
					}
					else
					{
						$r = call_user_func($func, $m);
					}
					if (!is_a($r, 'xmlrpcresp'))
					{
						error_log("XML-RPC: ".__METHOD__.": function $func registered as method handler does not return an xmlrpcresp object");
						if (is_a($r, 'xmlrpcval'))
						{
							$r = new jsonrpcresp($r);
						}
						else
						{
							$r = new jsonrpcresp(
								0,
								$GLOBALS['xmlrpcerr']['server_error'],
								$GLOBALS['xmlrpcstr']['server_error'] . ": function does not return jsonrpcresp or xmlrpcresp object"
							);
						}
					}
				}
				else
				{
					// call a 'plain php' function
					if($sysCall)
					{
						array_unshift($params, $this);
						$r = call_user_func_array($func,$params);
					}
					else
					{
						// 3rd API convention for method-handling functions: EPI-style
						if ($this->functions_parameters_type == 'epivals')
						{
							$r = call_user_func_array($func, array($methName, $params, $this->user_data));
							// mimic EPI behaviour: if we get an array that looks like an error, make it
							// an eror response
							if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r))
							{
								$r = new jsonrpcresp(0, (integer)$r['faultCode'], (string)$r['faultString']);
							}
							else
							{
								// functions using EPI api should NOT return resp objects,
								// so make sure we encode the return type correctly
								$r = new jsonrpcresp(php_xmlrpc_encode($r, array('extension_api')));
							}
						}
						else
						{
							$r = call_user_func_array($func, $params);
						}
					}
					// the return type can be either an xmlrpcresp object or a plain php value...
					if (!is_a($r, 'xmlrpcresp'))
					{
						// what should we assume here about automatic encoding of datetimes
						// and php classes instances???
						$r = new jsonrpcresp(php_jsonrpc_encode($r, $this->phpvals_encoding_options));
					}
				}
				// here $r is either an xmlrpcresp or jsonrpcresp
				if (!is_a($r, 'jsonrpcresp'))
				{

					// dirty trick: user has given us back an xmlrpc response,
					// since he had an existing xmlrpc server with boatloads of code.
					// Be nice to him, and serialize the xmlrpc stuff into JSON.
					// We also override the content_type of the xmlrpc response,
					// but lack knoweledge of intented response charset...
					$r->content_type = 'application/json';
					$r->payload = serialize_jsonrpcresp($r, $msgID);
				}
				else
				{
					$r->id = $msgID;
				}
			}
			catch(Exception $e)
			{
			// (barring errors in the lib) an uncatched exception happened
				// in the called function, we wrap it in a proper error-response
				switch($this->exception_handling)
				{
					case 2:
						throw $e;
						break;
					case 1:
						$r = new jsonrpcresp(0, $e->getCode(), $e->getMessage());
						break;
					default:
						$r = new jsonrpcresp(0, $GLOBALS['xmlrpcerr']['server_error'], $GLOBALS['xmlrpcstr']['server_error']);
				}
			}
			if($this->debug > 2)
			{
				// note: restore the error handler we found before calling the
				// user func, even if it has been changed inside the func itself
				if($GLOBALS['_xmlrpcs_prev_ehandler'])
				{
					set_error_handler($GLOBALS['_xmlrpcs_prev_ehandler']);
				}
				else
				{
					restore_error_handler();
				}
			}
			return $r;
		}
829957
public function getQuery()
    {
        if (is_null($this->_sQuery)) {
            $query = "";
            if ($params = $this->getParameters()) {
                $params = $this->_prepareQueryParameters($params);
                $query = http_build_query($params, "", "&");
            }
            $this->setQuery($query);
        }

        return $this->_sQuery;
    }
1267884
public function execute($params = array())
    {
        $this->mergeParams($params);

        $reconnect = $this->db->getOption('reconnect');
        $reconnectRetries = $this->db->getOption('reconnect_retries', 3);
        $reconnectDelayMS = $this->db->getOption('reconnect_delay_ms', 1000);

        while (true) {
            $e = null;
            $errorCode = null;
            $errorInfo = null;
            $result = null;

            $isReconnectError = false;
            try {
                $this->prepare();
                foreach ($this->positionParams as $index => $value) {
                    $this->statement->bindValue($index + 1, $value);
                }

                $result = $this->statement->execute($this->params?:null);
            } catch (\Exception $e) {
            }

            if ($result === false || !$e) {
                $errorCode = $this->statement->errorCode();
                $errorInfo = $this->statement->errorInfo();
            }

            $isReconnectError = Util::checkReconnectError($errorCode, $errorInfo, $e);

            // reconnect
            if ($reconnect && $isReconnectError && $reconnectRetries > 0) {
                $reconnectRetries--;
                $this->statement = null;
                $this->db->close();
                $reconnectDelayMS && usleep($reconnectDelayMS * 1000);
                continue;
            }

            break;
        }

        if ($e) {
            $this->db->logError(sprintf('Statement exception error #%s: %s', $e->getCode(), $e->getMessage()));
            throw $e;
        }

        if ($result === false) {
            $this->db->logError(sprintf('Statement execute error #%s: %s', $errorInfo[0], $errorInfo[2]));
            return false;
        }

        return $this->statement->rowCount();
    }