key_exists( $key, $this->data ) ) { $this->data[ $key ] = array_merge( $this->data[ $key ], $option ); } else { $this->data[ $key ] = $option; } // Greater than should never occur, bu to be safe if ( count( $option ) >= $config['chunk'] ) { $this->load_split_option( $key, $chunk + 1 ); } } /** * Load data for a specific chunk. * * Ideally this would be replaced with a closure passed to the storage cursor. * * @param string $key * @param int $chunk * * @return mixed|null */ public function _load_chunk( $key, $chunk ) { global $wpdb; $option = $wpdb->get_var( $wpdb->prepare( "SELECT `storage_data` FROM {$wpdb->base_prefix}itsec_distributed_storage WHERE `storage_group` = %s AND `storage_key` = %s AND `storage_chunk` = %d", $this->name, $key, $chunk ) ); if ( null === $option ) { return null; } $config = $this->config[ $key ]; return call_user_func( $config['unserialize'], $option ); } /** * Clear all the storage for a given group name. * * @param string $name * * @return bool */ public static function clear_group( $name ) { global $wpdb; $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->base_prefix}itsec_distributed_storage WHERE `storage_group` = %s", $name ) ); return $wpdb->last_error ? false : true; } } class ITSEC_Lib_Distributed_Storage_Cursor implements Iterator { /** @var ITSEC_Lib_Distributed_Storage */ private $storage; /** @var string */ private $key; /** @var int */ private $chunk = 0; /** @var array */ private $data; /** @var int */ private $iterated_count = 0; /** * ITSEC_Lib_Distributed_Storage_Cursor constructor. * * @param ITSEC_Lib_Distributed_Storage $storage * @param string $key * @param array $data */ public function __construct( ITSEC_Lib_Distributed_Storage $storage, $key, array $data ) { $this->storage = $storage; $this->key = $key; $this->data = $data; } /** * @inheritDoc */ public function current() { return current( $this->data ); } /** * @inheritDoc */ public function next() { if ( $this->iterated_count === count( $this->data ) - 1 ) { $data = $this->storage->_load_chunk( $this->key, $this->chunk + 1 ); if ( null !== $data ) { $this->data = $data; $this->iterated_count = 0; $this->chunk ++; return; } } $this->iterated_count ++; next( $this->data ); } /** * @inheritDoc */ public function key() { return key( $this->data ); } /** * @inheritDoc */ public function valid() { return $this->iterated_count < count( $this->data ); } /** * @inheritDoc */ public function rewind() { $this->iterated_count = 0; if ( 0 === $this->chunk ) { reset( $this->data ); } else { $data = $this->storage->_load_chunk( $this->key, 0 ); $this->data = null === $data ? array() : $data; $this->chunk = 0; } } } کودک Archives - صفحه 5 از 5 - انتشارات جامعة القرآن الکریم
سبد خرید - 0 مورد

سبد خرید شما خالی است.