本文整理汇总了PHP中Connection类的典型用法代码示例。如果您正苦于以下问题:PHP Connection类的具体用法?PHP Connection怎么用?PHP Connection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Connection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: perform
public function perform()
{
if (!$this->canPerform()) {
return;
}
$news = $this->getNews();
if (empty($news)) {
return;
}
$urls = array();
foreach ($news as $news) {
if (!empty($news->url)) {
$urls[$news->buildUrl(array(), false)][] = $news;
}
}
$c = new Connection(array(CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_NOBODY => true, CURLOPT_MAXREDIRS => 1));
foreach ($urls as $url => $news) {
$c->addRequest(new ConnectionRequest($url));
}
$requests = $c->run();
foreach ($requests as $i => $request) {
foreach ($urls[$request->url] as $news) {
$result = $request->reply->result == 0 ? $request->reply->info['http_code'] : $request->reply->result;
/** @var News $news */
if ($news->url_status != $result) {
$news->updateByPk($news->id, array('url_status' => $result));
if ($result !== 200) {
SMail::sendMail(Yii::app()->params->notifyEmail, 'Новость "' . $news->name . '" не доступна.', 'NewsUrlCheckError', array('news' => $news, 'request' => $request));
}
}
}
}
}
示例2: __construct
/**
* @param Connection $dbh
*/
public function __construct(Connection $conn)
{
$this->conn = $conn;
$this->dblink = $conn->getResource();
$dsn = $conn->getDSN();
$this->dbname = $dsn['database'];
}
示例3: insert
function insert($nroAula)
{
$claseConexion = new Connection();
$csql = "CALL SP_InsertAula(:nroAula)";
$claseConexion->queryWithParams($csql, array(':nroAula' => $nroAula));
return $claseConexion->getLastInsertedId();
}
示例4: _main
/**
* Function executed when the service is called
*
* @param Request
* @return Response
* */
public function _main(Request $request)
{
// display help for an specific service
if (!empty($request->query)) {
// check if the query passed is a service
$connection = new Connection();
$res = $connection->deepQuery("SELECT * FROM service WHERE name = '{$request->query}'");
if (count($res) > 0) {
$service = $res[0];
// update the valid email on the usage text
$utils = new Utils();
$validEmailAddress = $utils->getValidEmailAddress();
$usage = str_replace('{APRETASTE_EMAIL}', $validEmailAddress, $service->usage_text);
// send variables to the template
$responseContent = array("name" => $service->name, "description" => $service->description, "category" => $service->category, "usage" => nl2br($usage));
// create response for an specific service
$response = new Response();
$response->subject = "Ayuda para el servicio " . ucfirst($service->name);
$response->createFromTemplate("service.tpl", $responseContent);
return $response;
}
}
// create response
$responseContent = array("userEmail" => $request->email);
$response = new Response();
$response->subject = "Ayuda de Apretaste";
$response->createFromTemplate("basic.tpl", $responseContent);
return $response;
}
示例5: setCliente
public function setCliente(array $laCliente)
{
$loConnection = new Connection();
$stmt = $loConnection->prepare('INSERT INTO clientes(nome,cpf,tipoCliente,ativo,status) VALUES ("' . $laCliente['nome'] . '","' . $laCliente['cpf'] . '","' . $laCliente['tipoCliente'] . '",1,1)');
$stmt->execute();
header('location:index.php');
}
示例6: login
function login()
{
$authorized = false;
$error = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (strlen($_POST['userid']) > 0) {
$validation = new Validation();
if ($message = $validation->userid($_POST['userid'], 'ユーザー名')) {
$error[] = $message;
} else {
$userid = $_POST['userid'];
}
$_POST['password'] = trim($_POST['password']);
if ($message = $validation->alphaNumeric($_POST['password'], 'パスワード')) {
$error[] = $message;
} else {
$password = md5($_POST['password']);
}
if (count($error) <= 0) {
$connection = new Connection();
$query = sprintf("SELECT id,userid,password,realname,user_group,authority FROM %suser WHERE userid = '%s'", DB_PREFIX, $connection->quote($userid));
$data = $connection->fetchOne($query);
$connection->close();
if (count($data) > 0 && $data['userid'] === $userid && $data['password'] === $password) {
$authorized = true;
} else {
$error[] = 'ユーザー名もしくはパスワードが<br />異なります。';
}
}
} else {
$error[] = 'ユーザー名を入力してください。';
}
} elseif (isset($_SESSION['status'])) {
if ($_SESSION['status'] == 'idle') {
$error[] = '自動的にログアウトしました。<br />ログインしなおしてください。';
} elseif ($_SESSION['status'] == 'expire') {
$error[] = 'ログインの有効期限が切れました。<br />ログインしなおしてください。';
}
session_unregister('status');
}
if ($authorized === true && count($error) <= 0) {
session_regenerate_id();
$_SESSION['logintime'] = time();
$_SESSION['accesstime'] = $_SESSION['logintime'];
$_SESSION['authorized'] = md5(__FILE__ . $_SESSION['logintime']);
$_SESSION['userid'] = $data['userid'];
$_SESSION['realname'] = $data['realname'];
$_SESSION['group'] = $data['user_group'];
$_SESSION['authority'] = $data['authority'];
if (isset($_SESSION['referer'])) {
header('Location: ' . $_SESSION['referer']);
session_unregister('referer');
} else {
header('Location: index.php');
}
exit;
} else {
return $error;
}
}
示例7: createStatistics
/**
* {@inheritdoc}
*/
protected function createStatistics($type, $dateFrom, $dateTo = null, $id)
{
if (empty($dateFrom)) {
throw new \InvalidArgumentException("{$dateFrom} is invalid, a valid dateFrom must be passed");
}
//Check type, create objects accordingly
switch ($type) {
case parent::PUBLISHER:
$obj = new Publisher();
break;
case parent::WEBSITE:
$obj = new Website();
break;
case parent::ZONE:
$obj = new Zone();
break;
default:
throw new \InvalidArgumentException("{$type} is not a valid statistics set");
}
$host = $obj->getAddress($id) . "&from=" . $dateFrom;
if (!empty($dateTo)) {
$host = $host . "&to=" . $dateTo;
}
//connect to the API service
$connection = new Connection(new ArrayConfig(array("host" => $host, "key" => self::KEY, "sharedSecret" => self::SHARED_SECRET)));
//get the response from API connection
$arr = $connection->getResponse();
//API returns everything under one element, load it
$arr = $arr[0];
//set stats from result
$obj->setImpressions($arr["impressions"]);
$obj->setClicks($arr["clicks"]);
$obj->setRevenues($arr["revenue"]);
return $obj;
}
示例8: testConstructor
/**
* @covers PhiKettle\Kettle::__construct
* @covers PhiKettle\Kettle::getStream
* @covers PhiKettle\Kettle::getState
*/
public function testConstructor()
{
$connection = new Connection($this->host, $this->port, new DummyLoop());
$kettle = new Kettle($connection);
$this->assertEquals(new KettleState(), $kettle->getState());
$this->assertEquals($connection->getStream(), $kettle->getStream());
}
示例9: connect
protected static function connect($config)
{
$instance = new Connection();
$backupServer = array();
if (is_array(current($config))) {
foreach ($config as $host) {
if (isset($host['type']) && $host['type'] == 'backup') {
//作为集群二级缓存使用
unset($host['type']);
$backupServer[] = $host;
continue;
}
$persistent = isset($host['persistent']) ? $host['persistent'] : false;
$instance->addServer($host['host'], $host['port'], $persistent);
}
} else {
if (isset($config['host'])) {
if (!isset($config['port'])) {
$config['port'] = 11211;
}
$persistent = isset($host['persistent']) ? $host['persistent'] : false;
$instance->addServer($config['host'], $config['port'], $persistent);
}
}
if (!empty($backupServer)) {
$instance->setBackupInstance(self::connect($backupServer));
}
return $instance;
}
示例10: delete
function delete($details)
{
$conn = new Connection("auto");
$query = new Build();
$result = $query->delete($conn->grab_conn(), $details, "close");
return $result;
}
示例11: droppedAction
public function droppedAction()
{
// do not allow empty calls
if (empty($_POST)) {
die("EMPTY CALL");
}
// get the params from post
$email = $_POST['recipient'];
$domain = $_POST['domain'];
$reason = $_POST['reason'];
$code = isset($_POST['code']) ? $_POST['code'] : "";
$desc = isset($_POST['description']) ? str_replace("'", "", $_POST['description']) : "";
// do not save Spam as hardfail
if (stripos($desc, 'spam') !== false) {
$reason = "spam";
}
// mark as bounced if the email is part of the latest campaign
$connection = new Connection();
$campaign = $connection->deepQuery("\n\t\t\tSELECT campaign, email FROM (\n\t\t\t\tSELECT * FROM `campaign_sent`\n\t\t\t\tWHERE campaign = (SELECT id FROM campaign WHERE status='SENT' ORDER BY sending_date DESC LIMIT 1)\n\t\t\t) A WHERE email = '{$email}'");
if (count($campaign) > 0) {
// increase the bounce number for the campaign
$campaign = $campaign[0];
$connection->deepQuery("\n\t\t\t\tUPDATE campaign SET\tbounced=bounced+1 WHERE id={$campaign->campaign};\n\t\t\t\tUPDATE campaign_sent SET status='BOUNCED', date_opened=CURRENT_TIMESTAMP WHERE id={$campaign->campaign} AND email='{$email}'");
// unsubscribe from the list
$utils = new Utils();
$utils->unsubscribeFromEmailList($email);
}
// save into the database
$sql = "INSERT INTO delivery_dropped(email,sender,reason,code,description) VALUES ('{$email}','{$domain}','{$reason}','{$code}','{$desc}')";
$connection->deepQuery($sql);
// echo completion message
echo "FINISHED";
}
示例12: __construct
public function __construct(Connection $conn)
{
$this->conn = $conn;
$this->db = $conn->getDatabase();
$this->queue = $this->db->deferred_queue;
$this->refs = $this->db->references_queue;
}
示例13: getTiposClientes
public function getTiposClientes()
{
$loConnection = new Connection();
$stmt = $loConnection->prepare('SELECT * FROM tiposClientes WHERE status <> 0');
$stmt->execute();
return $stmt->fetchAll();
}
示例14: payment
/**
* Function executed when a payment is finalized
* Add new tickets to the database when the user pays
*
* @author salvipascual
* */
public function payment(Payment $payment)
{
// get the number of times the loop has to iterate
$numberTickets = null;
if ($payment->code == "1TICKET") {
$numberTickets = 1;
}
if ($payment->code == "5TICKETS") {
$numberTickets = 5;
}
if ($payment->code == "10TICKETS") {
$numberTickets = 10;
}
// do not give tickets for wrong codes
if (empty($numberTickets)) {
return false;
}
// create as many tickets as necesary
$query = "INSERT INTO ticket(email,origin) VALUES ";
for ($i = 0; $i < $numberTickets; $i++) {
$query .= "('{$payment->buyer}','PURCHASE')";
$query .= $i < $numberTickets - 1 ? "," : ";";
}
// save the tickets in the database
$connection = new Connection();
$transfer = $connection->deepQuery($query);
}
示例15: mainAction
public function mainAction()
{
// inicialize supporting classes
$connection = new Connection();
$email = new Email();
$service = new Service();
$service->showAds = false;
$render = new Render();
$response = new Response();
$utils = new Utils();
$wwwroot = $this->di->get('path')['root'];
// get valid people
$people = $connection->deepQuery("\n\t\t\tSELECT email, username, first_name, last_access\n\t\t\tFROM person\n\t\t\tWHERE active=1\n\t\t\tAND email not in (SELECT DISTINCT email FROM delivery_dropped)\n\t\t\tAND DATE(last_access) > DATE('2016-05-01')\n\t\t\tAND email like '%.cu'\n\t\t\tAND email not like '%@mms.cubacel.cu'");
// send the remarketing
$log = "";
foreach ($people as $person) {
// get the email address
$newEmail = "apretaste+{$person->username}@gmail.com";
// create the variabels to pass to the template
$content = array("newemail" => $newEmail, "name" => $person->first_name);
// create html response
$response->setEmailLayout("email_simple.tpl");
$response->createFromTemplate('newEmail.tpl', $content);
$response->internal = true;
$html = $render->renderHTML($service, $response);
// send the email
$email->sendEmail($person->email, "Sorteando las dificultades, un email lleno de alegria", $html);
$log .= $person->email . "\n";
}
// saving the log
$logger = new \Phalcon\Logger\Adapter\File("{$wwwroot}/logs/newemail.log");
$logger->log($log);
$logger->close();
}