function ExecuteApplication(ACmd: string; AWaitForTerminate: boolean=false; AHideWindow: boolean = false): THandle;
var
si: STARTUPINFO;
pi: PROCESS_INFORMATION;
begin
Result:=0;
try
ZeroMemory(@si,sizeof(si));
si.cb:=SizeOf(si);
si.dwFlags := STARTF_USESHOWWINDOW;
if AHideWindow then si.wShowWindow := SW_HIDE else si.wShowWindow := SW_SHOW;
if not CreateProcess(nil, PChar(ACmd), nil, nil, False, 0, nil, nil, si, pi)
then begin
Exit;
end;
Result:=pi.hProcess;
if AWaitForTerminate
then begin
WaitForSingleObject(pi.hProcess, INFINITE );
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
end;
except
end;
end;
INSERT INTO company (name, fullname, city) SELECT 'test', 'test', users.id
FROM users
WHERE users.guid = '5305cadc4456b'
uses
{...}, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, IdIOHandler, IdIOHandlerSocket, IdSSLOpenSSL;
{...}
var
IdHTTP1: TIdHTTP;
IdSSLIOHandlerSocket1: TIdSSLIOHandlerSocket;
response: WideString;
{...}
begin
{...}
// create HTTP client with SSL support
IdHTTP1:=TIdHTTP.Create(nil);
IdSSLIOHandlerSocket1:=TIdSSLIOHandlerSocket.Create(IdHTTP1);
IdSSLIOHandlerSocket1.SSLOptions.Method := sslvTLSv1;
IdHTTP1.IOHandler:=IdSSLIOHandlerSocket1;
response:=IdHTTP1.Post('https://...');
{...}
end;
class Template {
private $callback = array();
private $name = 'dummy';
private $data = array();
private function doCallback() {
foreach (array_reverse($this->callback) as $func) {
call_user_func_array(array($this, $func[0]), $func[1]);
}
$this->callback = array();
}
// реализация вызываемых методов (вызываются только из doCallback)
private function _render($name) {
echo "Call Render<br>\r\n";
$this->name = $name;
}
private function _withData($data) {
echo "Call WithData<br>\r\n";
$this->data = $data;
}
// эти функции записываются в стек и видны извне
public function render($name) {
$this->callback[]=array('_'.__FUNCTION__, func_get_args());
return $this;
}
public function withData($data) {
$this->callback[]=array('_'.__FUNCTION__, func_get_args());
return $this;
}
// конечная функция которая вызовет функции из стека в обратном порядке
public function __toString() {
$this->doCallback();
echo "Show output<br>\r\n";
return "";
}
// конечная функция которая вызовет функции из стека в обратном порядке
public function compile() {
$this->doCallback();
echo "Show output<br>\r\n";
}
}
$tpl = new Template;
$tpl->render('templateName')->withData(array('a','b','c'));
echo $tpl->compile(); // или echo $tpl;