Save data to log file

@param string $data
@param int $execTime
@param int $queryNr
8496
protected function save($data, $execTime, $queryNr)
    {
        $filePrefix = ($this->separateConsoleLog &&
        $this->app->runningInConsole()) ? '-artisan' : '';

        // save normal query to file if enabled
        if ($this->logStatus) {
            $this->saveLog($data, date('Y-m-d') . $filePrefix . '-log.sql',
                ($queryNr == 1 && (bool)$this->override));
        }

        // save slow query to file if enabled
        if ($this->slowLogStatus && $execTime >= $this->slowLogTime) {
            $this->saveLog($data,
                date('Y-m-d') . $filePrefix . '-slow-log.sql');
        }
    }
865736
public function insertData($data)
    {

        try {
            $location1 = new Order();
            $location1->order_no = $data['order_no'];
            $location1->order_desc = $data['order_desc'];
            $location1->full_address = $data['full_address'];
            $location1->user_id = $data['user_id'];
            $location1->user_name = $data['user_name'];
            $location1->user_mobile = $data['user_mobile'];
            $location1->merchant_id = $data['merchant_id'];
            $location1->merchant_name = $data['merchant_name'];
            $location1->merchant_tel = $data['merchant_tel'];
            $location1->published_at = $data['published_at'];
            $location1->user_lat = $data['user_lat'];
            $location1->user_lng = $data['user_lng'];
            $location1->geom = new GeomPoint($data['user_lng'], $data['user_lat']);
            $location1->big_cat = isset($data['big_cat']) ? $data['big_cat'] : '';
            $location1->middle_cat = isset($data['middle_cat']) ? $data['middle_cat'] : '';
            $location1->small_cat = isset($data['small_cat']) ? $data['small_cat'] : '';
            $location1->order_type = isset($data['order_type']) ? $data['order_type'] :0;
            $location1->biz_type = isset($data['biz_type']) ? $data['biz_type'] : 0;
            $location1->save();
        } catch (\Exception $e) {
            Log::info('c=OrderApiRepository f=insertData  msg=' . $e->getMessage());
            return false;
        }
        return $location1->getQueueableId();

    }
791202
public function log($query, $bindings, $time)
    {
        static $queryNr = 0;

        ++$queryNr;

        try {
            list($sqlQuery, $execTime) =
                $this->getSqlQuery($query, $bindings, $time);
        } catch (\Exception $e) {
            $this->app->log->notice("SQL query {$queryNr} cannot be bound: " .
                $query);

            return;
        }

        $logData = $this->getLogData($queryNr, $sqlQuery, $execTime);

        $this->save($logData, $execTime, $queryNr);
    }
976774
public function writeSession($id,$data)
	{
		// exception must be caught in session write handler
		// http://us.php.net/manual/en/function.session-set-save-handler.php
		try
		{
			$expire=time()+$this->getTimeout();
			$db=$this->getDbConnection();
			if($db->getDriverName()=='pgsql')
				$data=new CDbExpression($db->quoteValueWithType($data, PDO::PARAM_LOB)."::bytea");
			if($db->getDriverName()=='sqlsrv' || $db->getDriverName()=='mssql' || $db->getDriverName()=='dblib')
				$data=new CDbExpression('CONVERT(VARBINARY(MAX), '.$db->quoteValue($data).')');
			if($db->createCommand()->select('id')->from($this->sessionTableName)->where('id=:id',array(':id'=>$id))->queryScalar()===false)
				$db->createCommand()->insert($this->sessionTableName,array(
					'id'=>$id,
					'data'=>$data,
					'expire'=>$expire,
				));
			else
				$db->createCommand()->update($this->sessionTableName,array(
					'data'=>$data,
					'expire'=>$expire
				),'id=:id',array(':id'=>$id));
		}
		catch(Exception $e)
		{
			if(YII_DEBUG)
				echo $e->getMessage();
			// it is too late to log an error message here
			return false;
		}
		return true;
	}
613781
public function write($handle, string $data, $length = null) : int
    {
        $bytesWritten = is_int($length) ? fwrite($handle, $data, $length) : fwrite($handle, $data);

        if (false === $bytesWritten) {
            throw new FileException('Cannot write to a file.');
        }

        return $bytesWritten;
    }
186772
public function saveSearchResults(QueryModel $query)
    {
        $adapter = $this->getConnection();
        $table = $this->getMainTable();

        $numResults     = $query->getNumResults();
        $isSpellchecked = (int) $query->getIsSpellchecked();

        $saveData = [
            'store_id'        => $query->getStoreId(),
            'query_text'      => $query->getQueryText(),
            'num_results'     => $numResults,
            'is_spellchecked' => $isSpellchecked,
        ];

        $updateData = ['num_results' => $numResults, 'is_spellchecked' => $isSpellchecked];

        $adapter->insertOnDuplicate($table, $saveData, $updateData);
    }
1109719
public function save($data = null)
    {
        parent::save($data);

        // Invalidate configuration file from the opcache.
        if (\function_exists('opcache_invalidate')) {
            // PHP 5.5.5+
            @opcache_invalidate($this->filename, true);
        } elseif (\function_exists('apc_invalidate')) {
            // APC
            @apc_invalidate($this->filename);
        }
    }
1330307
public function store($key, $data, $expiration = 0) {
    $storeData = array(
      'time'   => time(),
      'expire' => $expiration,
      'data'   => serialize($data)
    );
    $dataArray = $this->_loadCache();
    if (true === is_array($dataArray)) {
      $dataArray[$key] = $storeData;
    } else {
      $dataArray = array($key => $storeData);
    }
    $cacheData = json_encode($dataArray);
    file_put_contents($this->getCacheDir(), $cacheData);
    return $this;
  }
1367166
public function storageLogin($key, $data, $expire = 0)
    {
        $key = $this->getKey($key);
        Session::set($key, $data);
    }
135291
public function write($data)
    {
        if (empty($this->filename)) {
            Throw new RepositoryException(sprintf('There is no filename set for %s', __CLASS__));
        }

        try {
            file_put_contents($this->filename, 'return ' . var_export($data, true));
        }
        catch (\Throwable $t) {
            Throw new RepositoryException($t->getMessage(), $t->getCode());
        }
    }
695606
public function addLog($data)
    {
        /* @var \Phalcon\Http\Request */
        $request = Di::getDefault()->getRequest();

        if (empty($data['ip_address'])) {
            $data['ip_address'] = $request->getClientAddress();
        }

        if (empty($data['user_agent'])) {
            $data['user_agent'] = $request->getUserAgent();
        }

        return $this->save($data);
    }
692963
protected function addExpirationCondition(
        QueryBuilder $query,
        int $expirationInSeconds,
        string $createdAtColumn
    ): QueryBuilder {
        $earliestExpired = $this->ignoreException(function () use ($expirationInSeconds) : DateTimeImmutable {
            return (new DateTimeImmutable())->sub(new DateInterval("PT{$expirationInSeconds}S"));
        });

        $query->andWhere($createdAtColumn . '>' . $this->createTypedParameter($query, $earliestExpired));

        return $query;
    }
651744
public function save( $key, $value, $expire = 0 ) {
		$key = $this->get_key( $key );
		wp_cache_set( $key, $value, $this->group, $expire );
	}
1200598
public function write(string $uri, $data)
    {
        // Create directory recursively if it doesn't exist
        if ( ! file_exists(dirname($uri))) {
            mkdir(dirname($uri), 0755, true);
        }

        // Write file to target directory
        if ( ! file_put_contents($uri, $data)) {
            throw new ErrorException("Failed to write output to file: ".$uri);
        }

        return true;
    }
872294
function save($parent_id = 0, $requestedSaveId = null, $createDefinition = true)
    {
        if ('' == trim($this->getTitle())) {
            throw new Exception('Must have a non blank title to save ' . $this->getType());
        }
        $levelId = $this->findEntityIdByTitle();
        if ($levelId) {
            $this->id = $levelId;
            return $levelId;
        }
        if ($requestedSaveId && $this->requestedIdCorrespondsToExistingRecord($requestedSaveId)) {
            $this->id = $requestedSaveId;
        }
        if ($this->getId()) {
            $sql = sprintf(
                "UPDATE %s SET `title` = %s WHERE id = %d",
                $this->getReadAdapter()->quoteIdentifier($this->getTable()),
                $this->getReadAdapter()->quote($this->getTitle()),
                (int)$this->getId()
            );
            $this->query($sql);
            return $this->id;
        }
        $data = array('title' => $this->getTitle());
        if ($requestedSaveId) {
            $data['id'] = $requestedSaveId;
        }
        $this->getReadAdapter()->insert($this->getTable(), $data);
        $levelId = $this->getReadAdapter()->lastInsertId();
        $this->setId($levelId);
        return $levelId;
    }
191998
public function write($key, $value, $expire = null) 
    {
        if (!$this->enabled) {
            return ;
        }

        if ($expire === null) {
            $expire = $this->expire;
        }
        
        $data = [
            'time'   => time(),
            'expire' => time() + $expire,
            'value'  => $value,
        ];
    
        $this->stats['execTimes'] ++;
        $this->stats['writeTimes'] ++;            
        $this->stats['writeSize'] += strlen(var_export($value, true))/1024;
        $this->temp[$key] = $data;
        
        try {
            $this->waitUnlock($key);
            $this->lock($key);
            $this->store($key, $data);
            $this->unlock($key);
        } catch (\wf\cache\Exception $e) {
            $this->unlock($key);
            throw $e;
        }
    }
664515
public function handle(QueryExecuted $event)
    {
        try {
            $bindings   = (array) $event->bindings;
            $duration   = $event->time;
            $connection = $event->connection->getName();
            $data       = \compact('bindings', 'duration', 'connection');

            // Format binding data
            foreach ($bindings as $i => $binding) {
                if ($binding instanceof DateTime) {
                    $bindings[$i] = $binding->format('Y-m-d H:i:s');
                } else {
                    if (\is_string($binding)) {
                        $bindings[$i] = "'$binding'";
                    }
                }
            }

            // Insert bindings into query
            $query_string = \str_replace(['%', '?'], ['%%', '%s'], $event->sql);
            $query_string = \vsprintf($query_string, $bindings);

            $this->logger->log($this->loggingLevel(), "Database query [$query_string]", $data);
        } catch (Exception $e) {
            $this->logger->error("Cannot log database query: {$e->getMessage()}", ['exception' => $e]);
        }
    }