idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
50,800 | public function setIsSystem ( $ value ) { assert ( null === $ value || is_bool ( $ value ) ) ; $ this -> _isSystem = $ value ; } | Set the isSystem value |
50,801 | public function setIsVolatile ( $ value ) { assert ( null === $ value || is_bool ( $ value ) ) ; $ this -> _isVolatile = $ value ; } | Set the isVolatile value |
50,802 | public function setNumberOfShards ( $ value ) { assert ( null === $ value || is_numeric ( $ value ) ) ; $ this -> _numberOfShards = $ value ; } | Set the numberOfShards value |
50,803 | public function setReplicationFactor ( $ value ) { assert ( null === $ value || is_numeric ( $ value ) || $ value === 'satellite' ) ; $ this -> _replicationFactor = $ value ; } | Set the replicationFactor value |
50,804 | public function setShardKeys ( $ value ) { assert ( null === $ value || is_array ( $ value ) ) ; $ this -> _shardKeys = $ value ; } | Set the shardKeys value |
50,805 | protected function makeCollection ( $ value ) { if ( $ value instanceof Collection ) { return $ value -> getName ( ) ; } if ( $ value instanceof Document ) { return $ value -> getCollectionId ( ) ; } return $ value ; } | Turn a value into a collection name |
50,806 | public static function validate ( $ value ) { assert ( is_string ( $ value ) ) ; if ( $ value !== self :: LAST && $ value !== self :: ERROR ) { throw new ClientException ( 'Invalid update policy' ) ; } } | Check if the supplied policy value is valid |
50,807 | public function installFoxxZip ( $ localZip , $ mountPoint , array $ options = [ ] ) { if ( ! file_exists ( $ localZip ) ) { throw new ClientException ( "Foxx-Zip {$localZip} does not exist (or file is unreadable)." ) ; } try { $ post = file_get_contents ( $ localZip ) ; $ response = $ this -> getConnection ( ) -> post... | Upload and install a foxx app . |
50,808 | public function removeFoxxApp ( $ mountPoint , array $ options = [ ] ) { try { $ response = $ this -> getConnection ( ) -> put ( Urls :: URL_FOXX_UNINSTALL , json_encode ( [ 'mount' => $ mountPoint ] ) ) ; if ( $ response -> getHttpCode ( ) < 400 ) { return $ response -> getJson ( ) ; } throw new ClientException ( spri... | Remove a foxx - app . |
50,809 | public function addUser ( $ username , $ passwd = null , $ active = null , $ extra = null ) { $ userDocument = new User ( ) ; $ userDocument -> user = $ username ; $ userDocument -> passwd = $ passwd ; $ userDocument -> active = $ active ; $ userDocument -> extra = $ extra ; $ data = $ userDocument -> getAll ( ) ; $ th... | save a user to the user - collection |
50,810 | public function replaceUser ( $ username , $ passwd = null , $ active = null , $ extra = null ) { $ userDocument = new User ( ) ; $ userDocument -> passwd = $ passwd ; $ userDocument -> active = $ active ; $ userDocument -> extra = $ extra ; $ data = $ userDocument -> getAll ( ) ; $ url = UrlHelper :: buildUrl ( Urls :... | Replace an existing user identified by its username |
50,811 | public function updateUser ( $ username , $ passwd = null , $ active = null , $ extra = null ) { $ userDocument = new User ( ) ; $ userDocument -> active = $ active ; if ( null !== $ passwd ) { $ userDocument -> passwd = $ passwd ; } if ( null !== $ active ) { $ userDocument -> active = $ active ; } if ( null !== $ ext... | Update an existing user identified by the username |
50,812 | public function get ( $ username ) { $ url = UrlHelper :: buildUrl ( Urls :: URL_USER , [ $ username ] ) ; $ response = $ this -> getConnection ( ) -> get ( $ url ) ; $ data = $ response -> getJson ( ) ; $ options = [ '_isNew' => false ] ; $ _documentClass = $ this -> _documentClass ; return $ _documentClass :: createF... | Get a single user - document identified by the username |
50,813 | public function removeUser ( $ username ) { $ params = [ ] ; $ url = UrlHelper :: buildUrl ( Urls :: URL_USER , [ $ username ] ) ; $ url = UrlHelper :: appendParamsUrl ( $ url , $ params ) ; $ this -> getConnection ( ) -> delete ( $ url ) ; return true ; } | Remove a user identified by the username |
50,814 | public function getDatabasePermissionLevel ( $ username , $ databaseName ) { $ url = UrlHelper :: buildUrl ( Urls :: URL_USER , [ $ username , 'database' , $ databaseName ] ) ; $ response = $ this -> getConnection ( ) -> get ( $ url ) ; $ data = $ response -> getJson ( ) ; return $ data [ 'result' ] ; } | Gets the list of collections a user has access to |
50,815 | public function register ( $ name = null , $ code = null ) { $ attributes = $ this -> attributes ; if ( $ name ) { $ attributes [ 'name' ] = $ name ; } if ( $ code ) { $ attributes [ 'code' ] = $ code ; } $ response = $ this -> _connection -> post ( Urls :: URL_AQL_USER_FUNCTION , $ this -> getConnection ( ) -> json_en... | Registers the user function |
50,816 | public function unregister ( $ name = null , $ namespace = false ) { if ( null === $ name ) { $ name = $ this -> getName ( ) ; } $ url = UrlHelper :: buildUrl ( Urls :: URL_AQL_USER_FUNCTION , [ $ name ] ) ; if ( $ namespace ) { $ url = UrlHelper :: appendParamsUrl ( $ url , [ 'group' => true ] ) ; } $ response = $ thi... | Un - register the user function |
50,817 | public function getRegisteredUserFunctions ( $ namespace = null ) { $ url = UrlHelper :: buildUrl ( Urls :: URL_AQL_USER_FUNCTION , [ ] ) ; if ( null !== $ namespace ) { $ url = UrlHelper :: appendParamsUrl ( $ url , [ 'namespace' => $ namespace ] ) ; } $ response = $ this -> _connection -> get ( $ url ) ; $ data = $ r... | Get registered user functions |
50,818 | public function execute ( ) { $ data = [ self :: ENTRY_FLUSH => $ this -> _flush , self :: ENTRY_COUNT => true ] ; if ( $ this -> _batchSize > 0 ) { $ data [ self :: ENTRY_BATCHSIZE ] = $ this -> _batchSize ; } if ( $ this -> _limit > 0 ) { $ data [ self :: ENTRY_LIMIT ] = $ this -> _limit ; } if ( is_array ( $ this ->... | Execute the export |
50,819 | private function setBatchRequest ( $ state ) { $ this -> _connection -> setBatchRequest ( $ state ) ; $ this -> _processed = true ; return $ this ; } | Sets connection into Batch - Request mode . This is necessary to distinguish between normal and the batch request . |
50,820 | public function append ( $ method , $ request ) { preg_match ( '%/_api/simple/(?P<simple>\w*)|/_api/(?P<direct>\w*)%ix' , $ request , $ regs ) ; if ( ! isset ( $ regs [ 'direct' ] ) ) { $ regs [ 'direct' ] = '' ; } $ type = $ regs [ 'direct' ] !== '' ? $ regs [ 'direct' ] : $ regs [ 'simple' ] ; if ( $ method === 'GET'... | Append the request to the batch - part |
50,821 | public function splitWithContentIdKey ( $ pattern , $ string ) { $ array = [ ] ; $ exploded = explode ( $ pattern , $ string ) ; foreach ( $ exploded as $ key => $ value ) { $ response = new HttpResponse ( $ value ) ; $ contentId = $ response -> getHeader ( 'Content-Id' ) ; if ( null !== $ contentId ) { $ array [ $ con... | Split batch request and use ContentId as array key |
50,822 | public function process ( ) { if ( $ this -> isCapturing ( ) ) { $ this -> stopCapture ( ) ; } $ this -> setBatchRequest ( true ) ; $ data = '' ; $ batchParts = $ this -> getBatchParts ( ) ; if ( count ( $ batchParts ) === 0 ) { throw new ClientException ( 'Can\'t process empty batch.' ) ; } $ combinedDataHeader = '--'... | Processes this batch . This sends the captured requests to the server as one batch . |
50,823 | public static function validate ( $ value ) { if ( is_string ( $ value ) || is_int ( $ value ) || is_float ( $ value ) || is_bool ( $ value ) || null === $ value ) { return ; } if ( is_array ( $ value ) ) { foreach ( $ value as $ subValue ) { self :: validate ( $ subValue ) ; } return ; } throw new ClientException ( 'I... | Validate the value of a variable |
50,824 | public function offsetGet ( $ offset ) { if ( ! array_key_exists ( $ offset , $ this -> _values ) ) { throw new ClientException ( 'Invalid option ' . $ offset ) ; } return $ this -> _values [ $ offset ] ; } | Get a specific option necessary for ArrayAccess |
50,825 | public function getCurrentEndpoint ( ) { assert ( is_array ( $ this -> _values [ self :: OPTION_ENDPOINT ] ) ) ; return $ this -> _values [ self :: OPTION_ENDPOINT ] [ $ this -> _currentEndpointIndex ] ; } | Get the current endpoint to use |
50,826 | public function haveMultipleEndpoints ( ) { assert ( is_array ( $ this -> _values [ self :: OPTION_ENDPOINT ] ) ) ; return count ( $ this -> _values [ self :: OPTION_ENDPOINT ] ) > 1 ; } | Whether or not we have multiple endpoints to connect to |
50,827 | public function addEndpoint ( $ endpoint ) { if ( ! is_string ( $ endpoint ) || ! Endpoint :: isValid ( $ endpoint ) ) { throw new ClientException ( sprintf ( "invalid endpoint specification '%s'" , $ endpoint ) ) ; } $ endpoint = Endpoint :: normalize ( $ endpoint ) ; $ normalized = Endpoint :: normalizeHostname ( $ e... | Add a new endpoint to the list of endpoints if the endpoint is already in the list it will not be added again as a side - effect this method will modify _currentEndpointIndex |
50,828 | public function nextEndpoint ( ) { assert ( is_array ( $ this -> _values [ self :: OPTION_ENDPOINT ] ) ) ; $ endpoints = $ this -> _values [ self :: OPTION_ENDPOINT ] ; $ numberOfEndpoints = count ( $ endpoints ) ; $ this -> _currentEndpointIndex ++ ; if ( $ this -> _currentEndpointIndex >= $ numberOfEndpoints ) { $ th... | Return the next endpoint from the list of endpoints As a side - effect this function switches to a new endpoint |
50,829 | private function loadOptionsFromCache ( ) { $ cache = $ this -> getEndpointsCache ( ) ; if ( $ cache === null ) { return ; } $ endpoints = $ cache -> get ( $ this -> _values [ self :: OPTION_MEMCACHED_ENDPOINTS_KEY ] ) ; if ( $ endpoints ) { $ this -> _values [ self :: OPTION_ENDPOINT ] = $ endpoints ; if ( ! is_array ... | load and merge connection options from optional Memcached cache into ihe current settings |
50,830 | private function storeOptionsInCache ( ) { $ endpoints = $ this -> _values [ self :: OPTION_ENDPOINT ] ; $ numberOfEndpoints = count ( $ endpoints ) ; if ( $ numberOfEndpoints <= 1 ) { return ; } $ cache = $ this -> getEndpointsCache ( ) ; if ( $ cache === null ) { return ; } $ update = [ $ endpoints [ $ this -> _curre... | store the updated options in the optional Memcached cache |
50,831 | private function getEndpointsCache ( ) { if ( $ this -> _cache === null ) { if ( ! isset ( $ this -> _values [ self :: OPTION_MEMCACHED_SERVERS ] ) ) { return null ; } if ( ! class_exists ( 'Memcached' , false ) ) { return null ; } $ servers = $ this -> _values [ self :: OPTION_MEMCACHED_SERVERS ] ; if ( ! is_array ( $... | Initialize and return a memcached cache instance if option memcachedServers is set |
50,832 | public function getHttpCodeDefinition ( ) { if ( ! isset ( $ this -> _httpCodeDefinitions [ $ this -> getHttpCode ( ) ] ) ) { throw new ClientException ( 'Invalid http code provided.' ) ; } return $ this -> _httpCodeDefinitions [ $ this -> getHttpCode ( ) ] ; } | Get the http code definition |
50,833 | public function create ( $ collection , array $ options = [ ] ) { if ( is_string ( $ collection ) ) { $ name = $ collection ; $ collection = new Collection ( ) ; $ collection -> setName ( $ name ) ; foreach ( $ options as $ key => $ value ) { $ collection -> { 'set' . ucfirst ( $ key ) } ( $ value ) ; } } if ( $ collec... | Creates a new collection on the server |
50,834 | public function has ( $ collection ) { $ collection = $ this -> makeCollection ( $ collection ) ; try { $ this -> get ( $ collection ) ; return true ; } catch ( ServerException $ e ) { if ( $ e -> getCode ( ) === 404 ) { return false ; } throw $ e ; } } | Check if a collection exists |
50,835 | public function count ( $ collection ) { $ collection = $ this -> makeCollection ( $ collection ) ; $ url = UrlHelper :: buildUrl ( Urls :: URL_COLLECTION , [ $ collection , self :: OPTION_COUNT ] ) ; $ response = $ this -> getConnection ( ) -> get ( $ url ) ; $ data = $ response -> getJson ( ) ; $ count = $ data [ sel... | Get the number of documents in a collection |
50,836 | public function get ( $ collection ) { $ collection = $ this -> makeCollection ( $ collection ) ; $ url = UrlHelper :: buildUrl ( Urls :: URL_COLLECTION , [ $ collection ] ) ; $ response = $ this -> getConnection ( ) -> get ( $ url ) ; $ data = $ response -> getJson ( ) ; return Collection :: createFromArray ( $ data )... | Get information about a collection |
50,837 | public function figures ( $ collection ) { $ collection = $ this -> makeCollection ( $ collection ) ; $ url = UrlHelper :: buildUrl ( Urls :: URL_COLLECTION , [ $ collection , self :: OPTION_FIGURES ] ) ; $ response = $ this -> getConnection ( ) -> get ( $ url ) ; $ data = $ response -> getJson ( ) ; return $ data [ se... | Get figures for a collection |
50,838 | public function getChecksum ( $ collectionId , $ withRevisions = false , $ withData = false ) { $ url = UrlHelper :: buildUrl ( Urls :: URL_COLLECTION , [ $ collectionId , self :: OPTION_CHECKSUM ] ) ; $ url = UrlHelper :: appendParamsUrl ( $ url , [ 'withRevisions' => $ withRevisions , 'withData' => $ withData ] ) ; $... | Calculate a checksum of the collection . |
50,839 | public function getRevision ( $ collectionId ) { $ url = UrlHelper :: buildUrl ( Urls :: URL_COLLECTION , [ $ collectionId , self :: OPTION_REVISION ] ) ; $ response = $ this -> getConnection ( ) -> get ( $ url ) ; return $ response -> getJson ( ) ; } | Returns the Collections revision ID |
50,840 | public function load ( $ collection ) { $ collectionId = $ this -> getCollectionId ( $ collection ) ; if ( $ this -> isValidCollectionId ( $ collectionId ) ) { throw new ClientException ( 'Cannot alter a collection without a collection id' ) ; } $ result = $ this -> getConnection ( ) -> put ( UrlHelper :: buildUrl ( Ur... | Load a collection into the server s memory |
50,841 | public function unload ( $ collection ) { $ collectionId = $ this -> getCollectionId ( $ collection ) ; if ( $ this -> isValidCollectionId ( $ collectionId ) ) { throw new ClientException ( 'Cannot alter a collection without a collection id' ) ; } $ result = $ this -> getConnection ( ) -> put ( UrlHelper :: buildUrl ( ... | Unload a collection from the server s memory |
50,842 | public function truncate ( $ collection ) { $ collectionId = $ this -> getCollectionId ( $ collection ) ; if ( $ this -> isValidCollectionId ( $ collectionId ) ) { throw new ClientException ( 'Cannot alter a collection without a collection id' ) ; } $ this -> getConnection ( ) -> put ( UrlHelper :: buildUrl ( Urls :: U... | Truncate a collection |
50,843 | public function drop ( $ collection , array $ options = [ ] ) { $ collectionName = $ this -> getCollectionName ( $ collection ) ; if ( $ this -> isValidCollectionId ( $ collectionName ) ) { throw new ClientException ( 'Cannot alter a collection without a collection id' ) ; } $ appendix = '' ; if ( is_array ( $ options ... | Drop a collection |
50,844 | public function getAllCollections ( array $ options = [ ] ) { $ options = array_merge ( [ 'excludeSystem' => false , 'keys' => 'result' ] , $ options ) ; $ params = [ ] ; if ( $ options [ 'excludeSystem' ] === true ) { $ params [ self :: OPTION_EXCLUDE_SYSTEM ] = true ; } $ url = UrlHelper :: appendParamsUrl ( Urls :: ... | Get list of all available collections per default with the collection names as index . Returns empty array if none are available . |
50,845 | public function importFromFile ( $ collectionId , $ importFileName , array $ options = [ ] ) { $ contents = file_get_contents ( $ importFileName ) ; if ( $ contents === false ) { throw new ClientException ( 'Input file "' . $ importFileName . '" could not be found.' ) ; } return $ this -> import ( $ collectionId , $ co... | Import documents from a file |
50,846 | public function import ( $ collection , $ importData , array $ options = [ ] ) { $ collection = $ this -> makeCollection ( $ collection ) ; $ tmpContent = '' ; if ( is_array ( $ importData ) ) { foreach ( $ importData as $ document ) { $ tmpContent .= $ document -> toJson ( ) . "\r\n" ; } $ importData = $ tmpContent ; ... | Import documents into a collection |
50,847 | public function createHashIndex ( $ collectionId , array $ fields , $ unique = null , $ sparse = null ) { $ indexOptions = [ ] ; if ( $ unique ) { $ indexOptions [ self :: OPTION_UNIQUE ] = ( bool ) $ unique ; } if ( $ sparse ) { $ indexOptions [ self :: OPTION_SPARSE ] = ( bool ) $ sparse ; } return $ this -> index ( ... | Create a hash index |
50,848 | public function createFulltextIndex ( $ collectionId , array $ fields , $ minLength = null ) { $ indexOptions = [ ] ; if ( $ minLength ) { $ indexOptions [ self :: OPTION_MIN_LENGTH ] = $ minLength ; } return $ this -> index ( $ collectionId , self :: OPTION_FULLTEXT_INDEX , $ fields , null , $ indexOptions ) ; } | Create a fulltext index |
50,849 | public function createSkipListIndex ( $ collectionId , array $ fields , $ unique = null , $ sparse = null ) { $ indexOptions = [ ] ; if ( $ unique ) { $ indexOptions [ self :: OPTION_UNIQUE ] = ( bool ) $ unique ; } if ( $ sparse ) { $ indexOptions [ self :: OPTION_SPARSE ] = ( bool ) $ sparse ; } return $ this -> inde... | Create a skip - list index |
50,850 | public function createPersistentIndex ( $ collectionId , array $ fields , $ unique = null , $ sparse = null ) { $ indexOptions = [ ] ; if ( $ unique ) { $ indexOptions [ self :: OPTION_UNIQUE ] = ( bool ) $ unique ; } if ( $ sparse ) { $ indexOptions [ self :: OPTION_SPARSE ] = ( bool ) $ sparse ; } return $ this -> in... | Create a persistent index |
50,851 | public function createGeoIndex ( $ collectionId , array $ fields , $ geoJson = null ) { $ indexOptions = [ ] ; if ( $ geoJson ) { $ indexOptions [ self :: OPTION_GEOJSON ] = ( bool ) $ geoJson ; } return $ this -> index ( $ collectionId , self :: OPTION_GEO_INDEX , $ fields , null , $ indexOptions ) ; } | Create a geo index |
50,852 | public function index ( $ collectionId , $ type , array $ attributes = [ ] , $ unique = false , array $ indexOptions = [ ] ) { $ urlParams = [ self :: OPTION_COLLECTION => $ collectionId ] ; $ bodyParams = [ self :: OPTION_TYPE => $ type , self :: OPTION_FIELDS => $ attributes , ] ; if ( $ unique !== null ) { $ bodyPar... | Creates an index on a collection on the server |
50,853 | public function getIndex ( $ collection , $ indexId ) { $ url = UrlHelper :: buildUrl ( Urls :: URL_INDEX , [ $ collection , $ indexId ] ) ; $ response = $ this -> getConnection ( ) -> get ( $ url ) ; return $ response -> getJson ( ) ; } | Get the information about an index in a collection |
50,854 | public function getIndexes ( $ collectionId ) { $ urlParams = [ self :: OPTION_COLLECTION => $ collectionId ] ; $ url = UrlHelper :: appendParamsUrl ( Urls :: URL_INDEX , $ urlParams ) ; $ response = $ this -> getConnection ( ) -> get ( $ url ) ; return $ response -> getJson ( ) ; } | Get indexes of a collection |
50,855 | public function dropIndex ( $ indexHandle ) { $ handle = explode ( '/' , $ indexHandle ) ; $ this -> getConnection ( ) -> delete ( UrlHelper :: buildUrl ( Urls :: URL_INDEX , [ $ handle [ 0 ] , $ handle [ 1 ] ] ) ) ; return true ; } | Drop an index |
50,856 | public function any ( $ collectionId ) { $ _documentClass = $ this -> _documentClass ; $ data = [ self :: OPTION_COLLECTION => $ collectionId , ] ; $ response = $ this -> getConnection ( ) -> put ( Urls :: URL_ANY , $ this -> json_encode_wrapper ( $ data ) ) ; $ data = $ response -> getJson ( ) ; if ( $ data [ 'documen... | Get a random document from the collection . |
50,857 | public function all ( $ collectionId , array $ options = [ ] ) { $ body = [ self :: OPTION_COLLECTION => $ collectionId , ] ; $ body = $ this -> includeOptionsInBody ( $ options , $ body , [ self :: OPTION_LIMIT => null , self :: OPTION_SKIP => null , ] ) ; $ response = $ this -> getConnection ( ) -> put ( Urls :: URL_... | Returns all documents of a collection |
50,858 | public function getAllIds ( $ collection ) { $ params = [ self :: OPTION_COLLECTION => $ this -> makeCollection ( $ collection ) ] ; $ response = $ this -> getConnection ( ) -> put ( Urls :: URL_ALL_KEYS , $ this -> json_encode_wrapper ( $ params ) ) ; $ data = $ response -> getJson ( ) ; if ( ! isset ( $ data [ Cursor... | Get the list of all documents ids from a collection |
50,859 | public function firstExample ( $ collectionId , $ document , array $ options = [ ] ) { $ _documentClass = $ this -> _documentClass ; if ( is_array ( $ document ) ) { $ document = $ _documentClass :: createFromArray ( $ document , $ options ) ; } if ( ! ( $ document instanceof Document ) ) { throw new ClientException ( ... | Get the first document matching a given example . |
50,860 | public function lookupByKeys ( $ collectionId , array $ keys , array $ options = [ ] ) { $ _documentClass = $ this -> _documentClass ; $ body = [ self :: OPTION_COLLECTION => $ collectionId , self :: OPTION_KEYS => $ keys ] ; $ response = $ this -> getConnection ( ) -> put ( Urls :: URL_LOOKUP_BY_KEYS , $ this -> json_... | Bulk lookup documents by specifying an array of keys |
50,861 | public function getServerVersion ( $ details = false ) { $ url = Urls :: URL_ADMIN_VERSION ; if ( $ details ) { $ url = UrlHelper :: appendParamsUrl ( $ url , [ 'details' => true ] ) ; } $ response = $ this -> getConnection ( ) -> get ( $ url ) ; $ data = $ response -> getJson ( ) ; if ( $ details ) { return $ data ; }... | Get the server version |
50,862 | public function getServerRole ( ) { $ url = Urls :: URL_ADMIN_SERVER_ROLE ; $ response = $ this -> getConnection ( ) -> get ( $ url ) ; $ data = $ response -> getJson ( ) ; return $ data [ 'role' ] ; } | Get the server role |
50,863 | public function getServerTime ( ) { $ response = $ this -> getConnection ( ) -> get ( Urls :: URL_ADMIN_TIME ) ; $ data = $ response -> getJson ( ) ; return $ data [ 'time' ] ; } | Get the server time |
50,864 | public function getServerLog ( array $ options = [ ] ) { $ url = UrlHelper :: appendParamsUrl ( Urls :: URL_ADMIN_LOG , $ options ) ; $ response = $ this -> getConnection ( ) -> get ( $ url ) ; return $ response -> getJson ( ) ; } | Get the server log |
50,865 | public function getNextBatch ( ) { if ( $ this -> _result === [ ] && $ this -> _hasMore ) { $ this -> fetchOutstanding ( ) ; } if ( $ this -> _result !== [ ] ) { $ result = $ this -> _result ; $ this -> _result = [ ] ; return $ result ; } return false ; } | Get next results as an array |
50,866 | public static function create ( Connection $ connection , $ name ) { $ payload = [ self :: ENTRY_DATABASE_NAME => $ name , self :: ENTRY_DATABASE_USERS => [ [ 'username' => $ connection -> getOption ( ConnectionOptions :: OPTION_AUTH_USER ) , 'passwd' => $ connection -> getOption ( ConnectionOptions :: OPTION_AUTH_PASS... | creates a database |
50,867 | public static function delete ( Connection $ connection , $ name ) { $ url = UrlHelper :: buildUrl ( Urls :: URL_DATABASE , [ $ name ] ) ; $ response = $ connection -> delete ( $ url ) ; return $ response -> getJson ( ) ; } | Deletes a database |
50,868 | public static function listUserDatabases ( Connection $ connection ) { $ url = UrlHelper :: buildUrl ( Urls :: URL_DATABASE , [ 'user' ] ) ; $ response = $ connection -> get ( $ url ) ; return $ response -> getJson ( ) ; } | List user databases |
50,869 | public function getAll ( ) { return [ self :: ENTRY_ID => $ this -> getId ( ) , self :: ENTRY_NAME => $ this -> getName ( ) , self :: ENTRY_TYPE => $ this -> getType ( ) , ] ; } | Return the view as an array |
50,870 | public function getResult ( ) { $ bodyParams = $ this -> attributes ; $ response = $ this -> _connection -> post ( Urls :: URL_TRAVERSAL , $ this -> getConnection ( ) -> json_encode_wrapper ( $ bodyParams ) ) ; return $ response -> getJson ( ) ; } | Execute and get the traversal result |
50,871 | public static function getDocumentIdFromLocation ( $ location ) { if ( ! is_string ( $ location ) ) { return null ; } if ( 0 === strpos ( $ location , '/_db/' ) ) { @ list ( , , , , , $ collectionName , $ id ) = explode ( '/' , $ location ) ; } else { @ list ( , , , $ collectionName , $ id ) = explode ( '/' , $ locatio... | Get the document id from a location header |
50,872 | public static function appendParamsUrl ( $ baseUrl , $ params ) { foreach ( $ params as $ key => & $ value ) { if ( is_bool ( $ value ) ) { $ value = self :: getBoolString ( $ value ) ; } } return $ baseUrl . '?' . http_build_query ( $ params ) ; } | Append parameters to a URL |
50,873 | public function clearSlow ( ) { $ url = UrlHelper :: buildUrl ( Urls :: URL_QUERY , [ 'slow' ] ) ; $ this -> getConnection ( ) -> delete ( $ url ) ; } | Clears the list of slow queries |
50,874 | public function getSlow ( ) { $ url = UrlHelper :: buildUrl ( Urls :: URL_QUERY , [ 'slow' ] ) ; $ response = $ this -> getConnection ( ) -> get ( $ url ) ; return $ response -> getJson ( ) ; } | Returns the list of slow queries |
50,875 | public function kill ( $ id ) { $ url = UrlHelper :: buildUrl ( Urls :: URL_QUERY , [ $ id ] ) ; $ this -> getConnection ( ) -> delete ( $ url ) ; return true ; } | Kills a specific query |
50,876 | public function setOption ( $ name , $ value ) { if ( $ name === ConnectionOptions :: OPTION_ENDPOINT || $ name === ConnectionOptions :: OPTION_HOST || $ name === ConnectionOptions :: OPTION_PORT || $ name === ConnectionOptions :: OPTION_VERIFY_CERT || $ name === ConnectionOptions :: OPTION_CIPHERS || $ name === Connec... | Set an option set for the connection |
50,877 | public function get ( $ url , array $ customHeaders = [ ] ) { return $ this -> handleFailover ( function ( ) use ( $ url , $ customHeaders ) { $ response = $ this -> executeRequest ( HttpHelper :: METHOD_GET , $ url , '' , $ customHeaders ) ; return $ this -> parseResponse ( $ response ) ; } ) ; } | Issue an HTTP GET request |
50,878 | public function post ( $ url , $ data , array $ customHeaders = [ ] ) { return $ this -> handleFailover ( function ( ) use ( $ url , $ data , $ customHeaders ) { $ response = $ this -> executeRequest ( HttpHelper :: METHOD_POST , $ url , $ data , $ customHeaders ) ; return $ this -> parseResponse ( $ response ) ; } ) ;... | Issue an HTTP POST request with the data provided |
50,879 | public function put ( $ url , $ data , array $ customHeaders = [ ] ) { return $ this -> handleFailover ( function ( ) use ( $ url , $ data , $ customHeaders ) { $ response = $ this -> executeRequest ( HttpHelper :: METHOD_PUT , $ url , $ data , $ customHeaders ) ; return $ this -> parseResponse ( $ response ) ; } ) ; } | Issue an HTTP PUT request with the data provided |
50,880 | public function head ( $ url , array $ customHeaders = [ ] ) { return $ this -> handleFailover ( function ( ) use ( $ url , $ customHeaders ) { $ response = $ this -> executeRequest ( HttpHelper :: METHOD_HEAD , $ url , '' , $ customHeaders ) ; return $ this -> parseResponse ( $ response ) ; } ) ; } | Issue an HTTP Head request with the data provided |
50,881 | public function patch ( $ url , $ data , array $ customHeaders = [ ] ) { return $ this -> handleFailover ( function ( ) use ( $ url , $ data , $ customHeaders ) { $ response = $ this -> executeRequest ( HttpHelper :: METHOD_PATCH , $ url , $ data , $ customHeaders ) ; return $ this -> parseResponse ( $ response ) ; } )... | Issue an HTTP PATCH request with the data provided |
50,882 | public function delete ( $ url , array $ customHeaders = [ ] , $ data = '' ) { return $ this -> handleFailover ( function ( ) use ( $ url , $ customHeaders , $ data ) { $ response = $ this -> executeRequest ( HttpHelper :: METHOD_DELETE , $ url , $ data , $ customHeaders ) ; return $ this -> parseResponse ( $ response ... | Issue an HTTP DELETE request with the data provided |
50,883 | private function updateHttpHeader ( ) { $ this -> _httpHeader = HttpHelper :: EOL ; $ endpoint = $ this -> _options -> getCurrentEndpoint ( ) ; if ( Endpoint :: getType ( $ endpoint ) !== Endpoint :: TYPE_UNIX ) { $ this -> _httpHeader .= sprintf ( 'Host: %s%s' , Endpoint :: getHost ( $ endpoint ) , HttpHelper :: EOL )... | Recalculate the static HTTP header string used for all HTTP requests in this connection |
50,884 | private function getHandle ( ) { if ( $ this -> _useKeepAlive && $ this -> _handle && is_resource ( $ this -> _handle ) ) { $ handle = $ this -> _handle ; if ( ! feof ( $ handle ) ) { return $ handle ; } $ this -> closeHandle ( ) ; if ( ! $ this -> _options [ ConnectionOptions :: OPTION_RECONNECT ] ) { throw new Client... | Get a connection handle |
50,885 | private function closeHandle ( ) { if ( $ this -> _handle && is_resource ( $ this -> _handle ) ) { @ fclose ( $ this -> _handle ) ; } $ this -> _handle = null ; } | Close an existing connection handle |
50,886 | public function parseResponse ( HttpResponse $ response ) { $ httpCode = $ response -> getHttpCode ( ) ; if ( $ httpCode < 200 || $ httpCode >= 400 ) { $ body = $ response -> getBody ( ) ; if ( $ body !== '' ) { $ details = json_decode ( $ body , true ) ; if ( is_array ( $ details ) && isset ( $ details [ 'errorNum' ] ... | Parse the response return the body values as an assoc array |
50,887 | private function doBatch ( $ method , $ request ) { $ batchPart = null ; if ( $ this -> _captureBatch === true ) { $ batch = $ this -> getActiveBatch ( ) ; $ batchPart = $ batch -> append ( $ method , $ request ) ; } return $ batchPart ; } | This is a helper function to executeRequest that captures requests if we re in batch mode |
50,888 | public static function check_encoding ( $ data ) { if ( ! is_array ( $ data ) ) { return ; } foreach ( $ data as $ key => $ value ) { if ( ! is_array ( $ value ) ) { if ( function_exists ( 'mb_detect_encoding' ) ) { if ( is_string ( $ key ) && mb_detect_encoding ( $ key , 'UTF-8' , true ) === false ) { throw new Client... | This function checks that the encoding of the keys and values of the array are utf - 8 recursively . It will raise an exception if it encounters wrong encoded strings . |
50,889 | public function setDatabase ( $ database ) { $ this -> _options [ ConnectionOptions :: OPTION_DATABASE ] = $ database ; $ this -> _database = $ database ; $ this -> updateHttpHeader ( ) ; } | Set the database to use with this connection |
50,890 | public static function getType ( $ value ) { if ( preg_match ( self :: REGEXP_TCP , $ value ) ) { return self :: TYPE_TCP ; } if ( preg_match ( self :: REGEXP_SSL , $ value ) ) { return self :: TYPE_SSL ; } if ( preg_match ( self :: REGEXP_UNIX , $ value ) ) { return self :: TYPE_UNIX ; } return null ; } | Return the type of an endpoint |
50,891 | public static function getHost ( $ value ) { if ( preg_match ( self :: REGEXP_TCP , $ value , $ matches ) ) { return preg_replace ( "/^http:/" , "tcp:" , $ matches [ 2 ] ) ; } if ( preg_match ( self :: REGEXP_SSL , $ value , $ matches ) ) { return preg_replace ( "/^https:/" , "ssl:" , $ matches [ 2 ] ) ; } return null ... | Return the host name of an endpoint |
50,892 | public static function createConnection ( ConnectionOptions $ options ) { $ endpoint = $ options -> getCurrentEndpoint ( ) ; $ context = stream_context_create ( ) ; if ( Endpoint :: getType ( $ endpoint ) === Endpoint :: TYPE_SSL ) { stream_context_set_option ( $ context , 'ssl' , 'verify_peer' , $ options [ Connection... | Create a one - time HTTP connection by opening a socket to the server |
50,893 | public static function validateMethod ( $ method ) { if ( $ method === self :: METHOD_POST || $ method === self :: METHOD_PUT || $ method === self :: METHOD_DELETE || $ method === self :: METHOD_GET || $ method === self :: METHOD_HEAD || $ method === self :: METHOD_PATCH ) { return true ; } throw new ClientException ( ... | Validate an HTTP request method name |
50,894 | public static function transfer ( $ socket , $ request , $ method ) { if ( ! is_resource ( $ socket ) ) { throw new ClientException ( 'Invalid socket used' ) ; } assert ( is_string ( $ request ) ) ; @ fwrite ( $ socket , $ request ) ; @ fflush ( $ socket ) ; $ contentLength = null ; $ expectedLength = null ; $ totalRea... | Execute an HTTP request on an opened socket |
50,895 | public static function parseHttpMessage ( $ httpMessage , $ originUrl = null , $ originMethod = null ) { return explode ( self :: SEPARATOR , $ httpMessage , 2 ) ; } | Splits an http message into its header and body . |
50,896 | public static function parseHeaders ( $ headers ) { $ httpCode = null ; $ result = null ; $ processed = [ ] ; foreach ( explode ( HttpHelper :: EOL , $ headers ) as $ lineNumber => $ line ) { if ( $ lineNumber === 0 ) { if ( preg_match ( "/^HTTP\/\d+\.\d+\s+(\d+)/" , $ line , $ matches ) ) { $ httpCode = ( int ) $ matc... | Process a string of HTTP headers into an array of header = > values . |
50,897 | public function set ( $ name , $ value = null ) { if ( is_array ( $ name ) ) { foreach ( $ name as $ value ) { ValueValidator :: validate ( $ value ) ; } $ this -> _values = $ name ; } else { if ( is_int ( $ name ) || is_string ( $ name ) ) { $ this -> _values [ ( string ) $ name ] = $ value ; ValueValidator :: validat... | Set the value of a single bind variable or set all bind variables at once |
50,898 | public function get ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> _values ) ) { return null ; } return $ this -> _values [ $ name ] ; } | Get the value of a bind variable with a specific name |
50,899 | public function has ( $ collection , $ documentId ) { try { $ this -> get ( $ collection , $ documentId ) ; return true ; } catch ( ServerException $ e ) { if ( $ e -> getCode ( ) === 404 ) { return false ; } throw $ e ; } } | Check if a document exists |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.