function saveBook( $blog_id, array $item ) {

		/** @var $wpdb \wpdb */
		global $wpdb;

		unset( $item['users_id'], $item['blogs_id'], $item['deleted'] ); // Don't allow spoofing

		$data = [
			'users_id' => $this->userId,
			'blogs_id' => $blog_id,
			'deleted' => 0,
		];
		$format = [
			'users_id' => $this->dbColumns['users_id'],
			'blogs_id' => $this->dbColumns['blogs_id'],
			'deleted' => $this->dbColumns['deleted'],
		];

		foreach ( $item as $key => $val ) {
			if ( isset( $this->dbColumns[ $key ] ) ) {
				$data[ $key ] = $val;
				$format[ $key ] = $this->dbColumns[ $key ];
			}
		}

		// INSERT ... ON DUPLICATE KEY UPDATE
		// @see http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

		$args = [];
		$sql = "INSERT INTO {$this->dbTable} ( ";
		foreach ( $data as $key => $val ) {
			$sql .= "`$key`, ";
		}
		$sql = rtrim( $sql, ', ' ) . ' ) VALUES ( ';

		foreach ( $format as $key => $val ) {
			$sql .= $val . ', ';
			$args[] = $data[ $key ];
		}
		$sql = rtrim( $sql, ', ' ) . ' ) ON DUPLICATE KEY UPDATE ';

		$i = 0;
		foreach ( $data as $key => $val ) {
			if ( 'users_id' === $key || 'blogs_id' === $key ) {
				continue;
			}
			$sql .= "`$key` = {$format[$key]}, ";
			$args[] = $val;
			++$i;
		}
		$sql = rtrim( $sql, ', ' );
		if ( ! $i ) {
			$sql .= ' users_id = users_id '; // Do nothing
		}

		return $wpdb->query( $wpdb->prepare( $sql, $args ) ); // @codingStandardsIgnoreLine
	}
function saveBook( $blog_id, array $item ) {

		/** @var $wpdb \wpdb */
		global $wpdb;

		unset( $item['users_id'], $item['blogs_id'], $item['deleted'] ); // Don't allow spoofing

		$data = [
			'users_id' => $this->userId,
			'blogs_id' => $blog_id,
			'deleted' => 0,
		];
		$format = [
			'users_id' => $this->dbColumns['users_id'],
			'blogs_id' => $this->dbColumns['blogs_id'],
			'deleted' => $this->dbColumns['deleted'],
		];

		foreach ( $item as $key => $val ) {
			if ( isset( $this->dbColumns[ $key ] ) ) {
				$data[ $key ] = $val;
				$format[ $key ] = $this->dbColumns[ $key ];
			}
		}

		// INSERT ... ON DUPLICATE KEY UPDATE
		// @see http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

		$args = [];
		$sql = "INSERT INTO {$this->dbTable} ( ";
		foreach ( $data as $key => $val ) {
			$sql .= "`$key`, ";
		}
		$sql = rtrim( $sql, ', ' ) . ' ) VALUES ( ';

		foreach ( $format as $key => $val ) {
			$sql .= $val . ', ';
			$args[] = $data[ $key ];
		}
		$sql = rtrim( $sql, ', ' ) . ' ) ON DUPLICATE KEY UPDATE ';

		$i = 0;
		foreach ( $data as $key => $val ) {
			if ( 'users_id' === $key || 'blogs_id' === $key ) {
				continue;
			}
			$sql .= "`$key` = {$format[$key]}, ";
			$args[] = $val;
			++$i;
		}
		$sql = rtrim( $sql, ', ' );
		if ( ! $i ) {
			$sql .= ' users_id = users_id '; // Do nothing
		}

		return $wpdb->query( $wpdb->prepare( $sql, $args ) ); // @codingStandardsIgnoreLine
	}
function saveBook ( $ blog_id , array $ item ) { /** @var $wpdb \wpdb */ global $ wpdb ; unset ( $ item [ 'users_id' ] , $ item [ 'blogs_id' ] , $ item [ 'deleted' ] ) ; // Don't allow spoofing $ data = [ 'users_id' => $ this -> userId , 'blogs_id' => $ blog_id , 'deleted' => 0 , ] ; $ format = [ 'users_id' => $ this -> dbColumns [ 'users_id' ] , 'blogs_id' => $ this -> dbColumns [ 'blogs_id' ] , 'deleted' => $ this -> dbColumns [ 'deleted' ] , ] ; foreach ( $ item as $ key => $ val ) { if ( isset ( $ this -> dbColumns [ $ key ] ) ) { $ data [ $ key ] = $ val ; $ format [ $ key ] = $ this -> dbColumns [ $ key ] ; } } // INSERT ... ON DUPLICATE KEY UPDATE // @see http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html $ args = [ ] ; $ sql = "INSERT INTO {$this->dbTable} ( " ; foreach ( $ data as $ key => $ val ) { $ sql .= "`$key`, " ; } $ sql = rtrim ( $ sql , ', ' ) . ' ) VALUES ( ' ; foreach ( $ format as $ key => $ val ) { $ sql .= $ val . ', ' ; $ args [ ] = $ data [ $ key ] ; } $ sql = rtrim ( $ sql , ', ' ) . ' ) ON DUPLICATE KEY UPDATE ' ; $ i = 0 ; foreach ( $ data as $ key => $ val ) { if ( 'users_id' === $ key || 'blogs_id' === $ key ) { continue ; } $ sql .= "`$key` = {$format[$key]}, " ; $ args [ ] = $ val ; ++ $ i ; } $ sql = rtrim ( $ sql , ', ' ) ; if ( ! $ i ) { $ sql .= ' users_id = users_id ' ; // Do nothing } return $ wpdb -> query ( $ wpdb -> prepare ( $ sql , $ args ) ) ; // @codingStandardsIgnoreLine }
Save a book to a user catalog.

@param $blog_id
@param array $item

@return int|false
Save a book to a user catalog .