• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Connection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Connection的典型用法代码示例。如果您正苦于以下问题:PHP Connection类的具体用法?PHP Connection怎么用?PHP Connection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Connection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
                 }
             }
         }
     }
 }
开发者ID:kbudylov,项目名称:ttarget,代码行数:33,代码来源:CampaignCheckNewsUrlJob.php


示例2: __construct

 /**
  * @param Connection $dbh
  */
 public function __construct(Connection $conn)
 {
     $this->conn = $conn;
     $this->dblink = $conn->getResource();
     $dsn = $conn->getDSN();
     $this->dbname = $dsn['database'];
 }
开发者ID:BackupTheBerlios,项目名称:nodin-svn,代码行数:10,代码来源:DatabaseInfo.php


示例3: insert

 function insert($nroAula)
 {
     $claseConexion = new Connection();
     $csql = "CALL SP_InsertAula(:nroAula)";
     $claseConexion->queryWithParams($csql, array(':nroAula' => $nroAula));
     return $claseConexion->getLastInsertedId();
 }
开发者ID:jmacboy,项目名称:electiva-programacion-2-2015-nur,代码行数:7,代码来源:AulaBLL.php


示例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;
 }
开发者ID:Apretaste,项目名称:Sandbox,代码行数:35,代码来源:service.php


示例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');
 }
开发者ID:Wenemy,项目名称:TrabalhoJoabe,代码行数:7,代码来源:Clientes.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;
     }
 }
开发者ID:rochefort8,项目名称:tt85,代码行数:60,代码来源:authority.php


示例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;
 }
开发者ID:Rcal,项目名称:api_sample_connection_app,代码行数:38,代码来源:StatisticsFactory.php


示例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());
 }
开发者ID:norbea,项目名称:PhiKettle,代码行数:12,代码来源:KettleTest.php


示例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;
 }
开发者ID:nangong92t,项目名称:go_src,代码行数:29,代码来源:Pool.php


示例10: delete

function delete($details)
{
    $conn = new Connection("auto");
    $query = new Build();
    $result = $query->delete($conn->grab_conn(), $details, "close");
    return $result;
}
开发者ID:hazbo2,项目名称:Outglow,代码行数:7,代码来源:omod_index.php


示例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";
 }
开发者ID:Apretaste,项目名称:Core,代码行数:33,代码来源:WebhookController.php


示例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;
 }
开发者ID:agpmedia,项目名称:activemongo2,代码行数:7,代码来源:Worker.php


示例13: getTiposClientes

 public function getTiposClientes()
 {
     $loConnection = new Connection();
     $stmt = $loConnection->prepare('SELECT * FROM tiposClientes WHERE status <> 0');
     $stmt->execute();
     return $stmt->fetchAll();
 }
开发者ID:Wenemy,项目名称:TrabalhoJoabe,代码行数:7,代码来源:TiposClientes.php


示例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);
 }
开发者ID:Apretaste,项目名称:rifa,代码行数:33,代码来源:service.php


示例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();
 }
开发者ID:Apretaste,项目名称:Core,代码行数:34,代码来源:NewemailTask.php


示例16: setNewConnection

    public static function setNewConnection($cookie)
    {
        // The old connections details are removed from the database in order to spare some memory
        Connection::cleanConnectionsPages();
        // A new connection is created if the guest made no actions during 30 minutes
        $result = Db::getInstance()->getRow('
		SELECT c.`id_guest`
		FROM `' . _DB_PREFIX_ . 'connections` c
		LEFT JOIN `' . _DB_PREFIX_ . 'connections_page` cp ON c.`id_connections` = cp.`id_connections`
		WHERE c.`id_guest` = ' . intval($cookie->id_guest) . '
		AND DATE_ADD(cp.`time_start`, INTERVAL 30 MINUTE) > \'' . pSQL(date('Y-m-d H:i:s')) . '\'
		ORDER BY cp.`time_start` DESC');
        if (!$result['id_guest'] and intval($cookie->id_guest)) {
            $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
            if (preg_replace('/^www./', '', parse_url($referer, PHP_URL_HOST)) == preg_replace('/^www./', '', $_SERVER['HTTP_HOST'])) {
                $referer = '';
            }
            $connection = new Connection();
            $connection->id_guest = intval($cookie->id_guest);
            $connection->id_page = Page::getCurrentId();
            $connection->ip_address = isset($_SERVER['REMOTE_ADDR']) ? ip2long($_SERVER['REMOTE_ADDR']) : '';
            if (Validate::isAbsoluteUrl($referer)) {
                $connection->http_referer = $referer;
            }
            $connection->add();
            $cookie->id_connections = $connection->id;
            return $connection->id_page;
        }
    }
开发者ID:sealence,项目名称:local,代码行数:29,代码来源:Connection.php


示例17: generateKey

 public function generateKey()
 {
     $key = "00000";
     $db = new Connection();
     $conn = $db->open();
     $sql = "SELECT id, `key` FROM urlmapping ORDER BY id DESC LIMIT 1";
     $result = $conn->query($sql);
     if ($result->num_rows > 0) {
         while ($row = $result->fetch_assoc()) {
             $key = $row["key"];
         }
     }
     for ($i = 4; $i >= 0; $i--) {
         $ascii = ord($key[$i]);
         if ($ascii < 122) {
             if ($ascii == 57) {
                 $ascii = 65;
             } else {
                 if ($ascii == 90) {
                     $ascii = 97;
                 } else {
                     $ascii++;
                 }
             }
             $key[$i] = chr($ascii);
             break;
         }
         $key[$i] = '0';
     }
     $conn->close();
     return $key;
 }
开发者ID:prayogo,项目名称:UrlShort,代码行数:32,代码来源:UrlData.php


示例18: addConnection

 public function addConnection(Connection $connection)
 {
     if (!isset($this->connections[$connection->getId()])) {
         $this->connections[$connection->getId()] = $connection;
     }
     return $this;
 }
开发者ID:holmesmedia,项目名称:java-script-remote-console,代码行数:7,代码来源:ConnectionRepository.php


示例19: getInstance

 static function getInstance(Connection $conn, $table_name)
 {
     if (self::$instance === NULL || !isset(self::$instance[$table_name])) {
         self::$instance[$table_name] = $conn->getDatabaseInfo()->getTable($table_name);
     }
     return self::$instance[$table_name];
 }
开发者ID:BackupTheBerlios,项目名称:medick-svn,代码行数:7,代码来源:Base.php


示例20: load

 public function load(Connection $connection)
 {
     if (!$connection->isConnected) {
         $connection->Connect();
     }
     if (!$connection->query($this->medicationQuery)) {
         return false;
     } else {
         $result = null;
         $medication = null;
         while ($result = $connection->getObject()) {
             $medication = new Medication();
             $medication->setCommonDose($result->commonDose);
             $medication->setGenericName($result->genericName);
             $medication->setRoute($result->route);
             $medication->setUnit($result->unit);
             $medication->setMedicationID($result->medicationId);
             $medication->setActive($result->active);
             $medication->setConfirmed($result->confirmed);
             $medication->setConfirmedBy($result->confirmedBy);
             array_push($this->medicationList, $medication);
         }
     }
     return true;
 }
开发者ID:nathanfl,项目名称:medtele,代码行数:25,代码来源:MAR.php



注:本文中的Connection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ConnectionFactory类代码示例发布时间:2022-05-23
下一篇:
PHP Connect类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap